Skip to content

Commit

Permalink
Merge pull request #4290 from alphagov/serach-results-metadata
Browse files Browse the repository at this point in the history
Reformat search results metadata to be more verbose
  • Loading branch information
owenatgov authored Nov 25, 2024
2 parents 3b481bf + ca306c3 commit 3bf7774
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 13 deletions.
8 changes: 2 additions & 6 deletions lib/metalsmith-lunr-index/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ const navigationConfig = require('../../config/navigation')
module.exports = function lunrPlugin() {
return (files, metalsmith, done) => {
const outputPath = 'search-index.json'

const separator =
'<span class="app-site-search__separator" aria-hidden="true">›</span>'

const includedSections = navigationConfig
.filter((section) => !section.ignoreInSearch)
.map((section) => section.label)
Expand Down Expand Up @@ -88,7 +84,7 @@ module.exports = function lunrPlugin() {
store[doc.permalink] = {
permalink: doc.permalink,
title: doc.title,
section: doc.section,
section: `in ${doc.section}`,
aliases: doc.aliases
}
this.add(doc)
Expand All @@ -98,7 +94,7 @@ module.exports = function lunrPlugin() {
store[doc.permalink] = {
permalink: doc.permalink,
title: doc.title,
section: `${doc.section}${separator}${doc.page}`,
section: `part of ${doc.page} in ${doc.section}`,
aliases: doc.aliases
}
this.add(doc)
Expand Down
2 changes: 1 addition & 1 deletion lib/metalsmith-lunr-index/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe('metalsmith-lunr-index plugin', () => {
({ title }) => title === 'Checkboxes'
)

expect(entry.section).toEqual('Components')
expect(entry.section).toEqual('in Components')
})

it('uses a custom permalink if in document metadata', () => {
Expand Down
6 changes: 0 additions & 6 deletions src/stylesheets/components/_site-search.scss
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,3 @@ $icon-size: 40px;
content: ")";
}
}

.app-site-search__separator {
display: inline-block;
margin-right: govuk-spacing(1);
margin-left: govuk-spacing(1);
}

0 comments on commit 3bf7774

Please sign in to comment.