From 8cf1171a65068d2f9cbac71d4b111930f1c9ea00 Mon Sep 17 00:00:00 2001 From: Cory LaViska Date: Thu, 13 Jul 2023 15:21:37 -0400 Subject: [PATCH] cleanup /index.html from search results --- docs/assets/scripts/search.js | 2 +- docs/eleventy.config.cjs | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/assets/scripts/search.js b/docs/assets/scripts/search.js index f524724cb..efcfa9571 100644 --- a/docs/assets/scripts/search.js +++ b/docs/assets/scripts/search.js @@ -284,7 +284,7 @@ const a = document.createElement('a'); const displayTitle = page.title ?? ''; const displayDescription = page.description ?? ''; - const displayUrl = page.url.replace(/^\//, ''); + const displayUrl = page.url.replace(/^\//, '').replace(/\/$/, ''); let icon = 'file-text'; a.setAttribute('role', 'option'); diff --git a/docs/eleventy.config.cjs b/docs/eleventy.config.cjs index e0e75221b..2377943fe 100644 --- a/docs/eleventy.config.cjs +++ b/docs/eleventy.config.cjs @@ -171,7 +171,10 @@ module.exports = function (eleventyConfig) { this.field('c'); // content results.forEach((result, index) => { - const url = path.join('/', path.relative(eleventyConfig.dir.output, result.outputPath)).replace(/\\/g, '/'); + const url = path + .join('/', path.relative(eleventyConfig.dir.output, result.outputPath)) + .replace(/\\/g, '/') // convert backslashes to forward slashes + .replace(/\/index.html$/, '/'); // convert trailing /index.html to / const doc = new JSDOM(result.content, { // We must set a default URL so links are parsed with a hostname. Let's use a bogus TLD so we can easily // identify which ones are internal and which ones are external.