From 386ccfa0aca6c7dbf2f4eafcfe9b8c2403c45ead Mon Sep 17 00:00:00 2001 From: James Bradbury Date: Tue, 15 Aug 2023 10:32:42 +0200 Subject: [PATCH] fix 421 --- src/lib/components/mosaic/RefCategory.svelte | 5 ++++- src/lib/components/mosaic/References.svelte | 21 ++++++++++++------- src/routes/(content)/reference/+page.svx | 22 +++++++++++--------- 3 files changed, 30 insertions(+), 18 deletions(-) diff --git a/src/lib/components/mosaic/RefCategory.svelte b/src/lib/components/mosaic/RefCategory.svelte index db3bee64..86f05a36 100644 --- a/src/lib/components/mosaic/RefCategory.svelte +++ b/src/lib/components/mosaic/RefCategory.svelte @@ -11,7 +11,7 @@
-

{item.category}

+

{item.category}

\ No newline at end of file diff --git a/src/routes/(content)/reference/+page.svx b/src/routes/(content)/reference/+page.svx index 02e174ea..480d6a74 100644 --- a/src/routes/(content)/reference/+page.svx +++ b/src/routes/(content)/reference/+page.svx @@ -21,28 +21,30 @@ layout: contentindex }; let query = ''; - references.forEach(r => { categorised[r.category].push(r) }); const search = new FuzzySearch(references, ['title', 'tags', 'blurb', 'category'], { caseSensitive: false, - sort: true + sort: false }) - function doSearch() { + function populateItems() { + return Object.entries(categorised).map(k => ({ "category" : k[0], "refs" : k[1] })); + } + let items = populateItems(); + function doSearch() { Object.keys(categorised).forEach(c => { categorised[c] = []; }); - - const searchResult = search.search(query); - searchResult.forEach(r => { + let result = query === '' ? references : search.search(query); + result.forEach(r => { categorised[r.category].push(r); }); - } - $: items = Object.entries(categorised).map(k => ({ "category" : k[0], "refs" : k[1] })); + items = populateItems(); + }

Reference

@@ -50,8 +52,8 @@ layout: contentindex
@@ -60,7 +62,7 @@ layout: contentindex