From 1edf5552329eeb176e573ece8e769860c5e3ec0c Mon Sep 17 00:00:00 2001 From: Owen Jones Date: Fri, 8 Nov 2024 16:33:07 +0000 Subject: [PATCH] Reformat search results metadata to be more verbose --- lib/metalsmith-lunr-index/index.js | 8 ++------ src/javascripts/components/search.mjs | 5 ----- src/stylesheets/components/_site-search.scss | 6 ------ 3 files changed, 2 insertions(+), 17 deletions(-) diff --git a/lib/metalsmith-lunr-index/index.js b/lib/metalsmith-lunr-index/index.js index fe1e7d0f4d..f8885b860c 100644 --- a/lib/metalsmith-lunr-index/index.js +++ b/lib/metalsmith-lunr-index/index.js @@ -5,10 +5,6 @@ const navigationConfig = require('../../config/navigation') module.exports = function lunrPlugin() { return (files, metalsmith, done) => { const outputPath = 'search-index.json' - - const separator = - '' - const includedSections = navigationConfig .filter((section) => !section.ignoreInSearch) .map((section) => section.label) @@ -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) @@ -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) diff --git a/src/javascripts/components/search.mjs b/src/javascripts/components/search.mjs index c82780b212..83afe767ed 100644 --- a/src/javascripts/components/search.mjs +++ b/src/javascripts/components/search.mjs @@ -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 } diff --git a/src/stylesheets/components/_site-search.scss b/src/stylesheets/components/_site-search.scss index cf0c231876..b963d363c7 100644 --- a/src/stylesheets/components/_site-search.scss +++ b/src/stylesheets/components/_site-search.scss @@ -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); -}