From eb59b06c465e968a956bef130351199c45d612b6 Mon Sep 17 00:00:00 2001 From: Akshay Date: Mon, 13 Sep 2021 00:50:18 +0200 Subject: [PATCH] Issue-545: Add content as index --- gatsby-config.js | 3 ++- package-lock.json | 14 ++++++++++++++ package.json | 1 + src/components/Search/SearchClient.jsx | 1 + src/components/Search/SearchComponent.jsx | 6 ++++-- 5 files changed, 22 insertions(+), 3 deletions(-) diff --git a/gatsby-config.js b/gatsby-config.js index ba9169a5..31879ac8 100755 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -170,6 +170,7 @@ module.exports = { path: `${__dirname}/markdowns/markdowns`, name: 'markdowns' } - } + }, + `gatsby-transformer-remark-plaintext` ] } diff --git a/package-lock.json b/package-lock.json index 90c37bac..6470ad06 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14411,6 +14411,15 @@ } } }, + "gatsby-transformer-remark-plaintext": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/gatsby-transformer-remark-plaintext/-/gatsby-transformer-remark-plaintext-1.0.3.tgz", + "integrity": "sha512-V6nU03WKW65Xy5DyQPeVSMf5KVNoXX2yHbq53H0u1a/MkakG3osNTDWiTDxVQ8kg9OZ/04Dblczg9QxRnLjrYA==", + "requires": { + "@babel/runtime": "^7.0.0", + "strip-markdown": "^3.0.2" + } + }, "gatsby-transformer-sharp": { "version": "2.12.1", "resolved": "https://registry.npmjs.org/gatsby-transformer-sharp/-/gatsby-transformer-sharp-2.12.1.tgz", @@ -23950,6 +23959,11 @@ "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.0.tgz", "integrity": "sha512-e6/d0eBu7gHtdCqFt0xJr642LdToM5/cN4Qb9DbHjVx1CP5RyeM+zH7pbecEmDv/lBqb0QH+6Uqq75rxFPkM0w==" }, + "strip-markdown": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/strip-markdown/-/strip-markdown-3.1.2.tgz", + "integrity": "sha512-NjwW6CEefesmHQPs7lof/lgnSriqUnRNOWpnrNPq9A7/yOCdnhaB7DcxlhYuN7WiiRUe349aitAsTQ/ajM9Dmw==" + }, "strip-outer": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/strip-outer/-/strip-outer-1.0.1.tgz", diff --git a/package.json b/package.json index c9f0ae77..beba29c7 100644 --- a/package.json +++ b/package.json @@ -45,6 +45,7 @@ "gatsby-source-git": "^1.1.0", "gatsby-source-graphql": "^2.14.0", "gatsby-transformer-remark": "^2.16.1", + "gatsby-transformer-remark-plaintext": "^1.0.3", "gatsby-transformer-sharp": "^2.12.1", "gatsby-transformer-xml": "^2.10.0", "gatsby-transformer-yaml": "^2.11.0", diff --git a/src/components/Search/SearchClient.jsx b/src/components/Search/SearchClient.jsx index 6fa08600..1ed26312 100644 --- a/src/components/Search/SearchClient.jsx +++ b/src/components/Search/SearchClient.jsx @@ -65,6 +65,7 @@ const SearchClient = ({ searchableData }) => { const dataToSearch = new JsSearch.Search('title') dataToSearch.addIndex('title') dataToSearch.addIndex('description') + dataToSearch.addIndex('text') dataToSearch.addDocuments(searchableData) setSearchState({ diff --git a/src/components/Search/SearchComponent.jsx b/src/components/Search/SearchComponent.jsx index 5b358fcc..e9a219eb 100644 --- a/src/components/Search/SearchComponent.jsx +++ b/src/components/Search/SearchComponent.jsx @@ -19,18 +19,20 @@ const SearchComponent = () => { description } id + plainText } } } } `) - + console.log('data', data) const searchableData = data.allMarkdownRemark.edges.map(({ node }) => { return { title: node.frontmatter.title, description: node.frontmatter.description, slug: node.fields.slug, - id: node.id + id: node.id, + text: node.plainText } }) return (