From ca306c38f0d0abc8231d2b9a1eb6c5f0f442523e 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 ++------ lib/metalsmith-lunr-index/index.test.js | 2 +- src/stylesheets/components/_site-search.scss | 6 ------ 3 files changed, 3 insertions(+), 13 deletions(-) diff --git a/lib/metalsmith-lunr-index/index.js b/lib/metalsmith-lunr-index/index.js index fe1e7d0f4d..cbd191b389 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/lib/metalsmith-lunr-index/index.test.js b/lib/metalsmith-lunr-index/index.test.js index 5875f54cf2..98c7aea08f 100644 --- a/lib/metalsmith-lunr-index/index.test.js +++ b/lib/metalsmith-lunr-index/index.test.js @@ -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', () => { 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); -}