Skip to content

Commit

Permalink
cleanup /index.html from search results (#1454)
Browse files Browse the repository at this point in the history
  • Loading branch information
claviska authored Jul 13, 2023
1 parent 414197a commit 2e2a683
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/assets/scripts/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
5 changes: 4 additions & 1 deletion docs/eleventy.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 2e2a683

Please sign in to comment.