Skip to content

Commit

Permalink
Reformat search results metadata to be more verbose
Browse files Browse the repository at this point in the history
  • Loading branch information
owenatgov committed Nov 12, 2024
1 parent 81cd431 commit 5f6b3ec
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 17 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: `<span class="govuk-visually-hidden">,</span> part of ${doc.page} in ${doc.section}`,
aliases: doc.aliases
}
this.add(doc)
Expand Down
5 changes: 0 additions & 5 deletions src/javascripts/components/search.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,6 @@ class Search extends Component {
section.className = 'app-site-search--section'
section.innerHTML = result.section

const visuallyHiddenComma = document.createElement('span')
visuallyHiddenComma.className = 'govuk-visually-hidden'
visuallyHiddenComma.innerHTML = ', '

elem.appendChild(visuallyHiddenComma)
elem.appendChild(section)
return elem.innerHTML
}
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 5f6b3ec

Please sign in to comment.