From be144e28e78689863e0a103370dd25e49a7ae5a1 Mon Sep 17 00:00:00 2001 From: Santhoshkumar <117272529+Santhosh-testsigma@users.noreply.github.com> Date: Fri, 2 Aug 2024 11:18:18 +0530 Subject: [PATCH] [WEB-1230] -> Input Caching in typesense search --- scripts/indexr.js | 13 ++++--- src/components/SearchHits.jsx | 4 +-- src/components/SearchHits.scss | 9 ++++- src/components/SearchInputBox.jsx | 57 +++++++++++++++++++++---------- src/templates/page.scss | 18 +++++++--- 5 files changed, 72 insertions(+), 29 deletions(-) diff --git a/scripts/indexr.js b/scripts/indexr.js index 1d8f002..d11c3a3 100644 --- a/scripts/indexr.js +++ b/scripts/indexr.js @@ -29,7 +29,7 @@ const pageQuery = ` fields { slug } - excerpt(pruneLength: 6700) + excerpt(pruneLength: 100) } } } @@ -37,11 +37,16 @@ const pageQuery = ` `; function pageToTypesenseRecord({ node }) { - const { id, frontmatter, ...rest } = node; - console.log('node', node); + const { id, frontmatter, fields = {}, headings = [], ...rest } = node; + + const formattedHeadings = headings.map(h => h.value || '').filter(Boolean); return { objectID: id, - ...frontmatter, + title: frontmatter.title || '', + search_keyword: String(frontmatter.search_keyword || ''), + slug: fields.slug || '', + excerpt: frontmatter.excerpt || '', + headings: formattedHeadings, ...rest, }; } diff --git a/src/components/SearchHits.jsx b/src/components/SearchHits.jsx index 98eca5f..6e2245b 100644 --- a/src/components/SearchHits.jsx +++ b/src/components/SearchHits.jsx @@ -22,10 +22,10 @@ export const CustomSearchBox = connectSearchBox(SearchBox); /* eslint-disable react/no-danger */ const Hits = ({ hits }) => (