diff --git a/pagefind/src/output/stubs/search.js b/pagefind/src/output/stubs/search.js index a34775b8..174c5476 100644 --- a/pagefind/src/output/stubs/search.js +++ b/pagefind/src/output/stubs/search.js @@ -177,7 +177,7 @@ class Pagefind { let ptr = await this.getPtr(); // Strip special characters to match the indexing operation let exact_search = /^\s*".+"\s*$/.test(term); - term = term.toLowerCase().trim().replace(/[^\w\s]/g, "").trim(); + term = term.toLowerCase().trim().replace(/[^\w\s]/g, "").replace(/\s{2,}/g, " ").trim(); let filter_list = []; for (let [filter, values] of Object.entries(options.filters)) { diff --git a/pagefind_ui/dev_files/_pagefind/pagefind.js b/pagefind_ui/dev_files/_pagefind/pagefind.js index 9b6fb6e7..f1c8d416 100644 --- a/pagefind_ui/dev_files/_pagefind/pagefind.js +++ b/pagefind_ui/dev_files/_pagefind/pagefind.js @@ -1,6 +1,68 @@ // This is a Pagefind testing stub that needs to be updated if src/output/search.js is changed const stubbed_results = [ + { + id: 123, + data: { + content: [ + `Cras mattis consectetur purus sit amet fermentum. Maecenas sed diam eget risus varius blandit sit amet non magna. Sed posuere consectetur est at lobortis. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.`, + `Cras mattis consectetur purus sit amet fermentum. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Curabitur blandit tempus porttitor. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras justo odio, dapibus ac facilisis in, egestas eget quam.`, + `Nullam id dolor id nibh ultricies vehicula ut id elit. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Donec ullamcorper nulla non metus auctor fringilla.` + ].join('\n'), + url: "/cats/", + filters: { + color: ["Red"] + }, + meta: { + title: `Post about TERM`, + image: "https://placekitten.com/800/400" + }, + word_count: 12, + excerpt: `some excerpt that references TERM with a nice highlighted element.` + } + }, + { + id: 1234, + data: { + content: [ + `Cras mattis consectetur purus sit amet fermentum. Maecenas sed diam eget risus varius blandit sit amet non magna. Sed posuere consectetur est at lobortis. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.`, + `Cras mattis consectetur purus sit amet fermentum. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Curabitur blandit tempus porttitor. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras justo odio, dapibus ac facilisis in, egestas eget quam.`, + `Nullam id dolor id nibh ultricies vehicula ut id elit. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Donec ullamcorper nulla non metus auctor fringilla.` + ].join('\n'), + url: "/dogs/", + filters: { + color: ["Blue", "Gold"] + }, + meta: { + title: `TERM and TERM-like things`, + image: "https://placekitten.com/1000/500" + }, + word_count: 15, + excerpt: `I like TERM and also TERM...` + } + }, + { + id: 12345, + data: { + content: [ + `Cras mattis consectetur purus sit amet fermentum. Maecenas sed diam eget risus varius blandit sit amet non magna. Sed posuere consectetur est at lobortis. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.`, + `Cras mattis consectetur purus sit amet fermentum. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Curabitur blandit tempus porttitor. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras justo odio, dapibus ac facilisis in, egestas eget quam.`, + `Nullam id dolor id nibh ultricies vehicula ut id elit. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Donec ullamcorper nulla non metus auctor fringilla.` + ].join('\n'), + url: "/llamas/", + filters: { + color: ["White"], + smell: ["Sweet"] + }, + meta: { + title: `TERM the llama`, + image: "https://placekitten.com/900/600", + name: "Steve" + }, + word_count: 100, + excerpt: `Nullam id dolor id nibh ultricies TERM vehicula ut id elit.` + } + }, { id: 123, data: { diff --git a/pagefind_ui/svelte/filters.svelte b/pagefind_ui/svelte/filters.svelte index 499f1fb7..c5c5f578 100644 --- a/pagefind_ui/svelte/filters.svelte +++ b/pagefind_ui/svelte/filters.svelte @@ -3,26 +3,29 @@ export const selected_filters = {}; -