Статьи
Последние статьи
+Последние статьи
смотреть всеСтатьи
+Категория: {title}
Показано {edges.edges.length} из категории "{title}"
Статьи
+Тэг: {title}
Показано {edges.edges.length} по тегу "{title}"
diff --git a/gatsby-config.js b/gatsby-config.js
index aba38cd..1e300ce 100644
--- a/gatsby-config.js
+++ b/gatsby-config.js
@@ -130,6 +130,56 @@ module.exports = {
],
},
},
+ {
+ resolve: 'gatsby-plugin-local-search',
+ options: {
+ name: 'pages',
+ engine: 'flexsearch',
+ engineOptions: 'speed',
+ query: `
+ {
+ allMarkdownRemark(filter: { frontmatter: { templateKey: { eq: "article" } } }) {
+ nodes {
+ id
+ frontmatter {
+ slug
+ title
+ category
+ image {
+ childImageSharp {
+ fluid(maxWidth: 960) {
+ aspectRatio
+ base64
+ sizes
+ src
+ srcSet
+ }
+ }
+ }
+ tags
+ description
+ }
+ rawMarkdownBody
+ }
+ }
+ }
+ `,
+ ref: 'id',
+ index: ['title', 'category', 'body', 'tags', 'description'],
+ store: ['id', 'slug', 'title', 'category', 'tags', 'description', 'image'],
+ normalizer: ({ data }) =>
+ data.allMarkdownRemark.nodes.map(node => ({
+ id: node.id,
+ slug: node.frontmatter.slug,
+ title: node.frontmatter.title,
+ category: node.frontmatter.category,
+ description: node.frontmatter.description,
+ image: node.frontmatter.image,
+ tags: node.frontmatter.tags,
+ body: node.rawMarkdownBody,
+ })),
+ },
+ },
{
resolve: 'gatsby-plugin-react-svg',
options: {
diff --git a/package-lock.json b/package-lock.json
index b99173d..7182506 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -8227,6 +8227,11 @@
"normalize.css": "^7.0.0"
}
},
+ "flexsearch": {
+ "version": "0.6.32",
+ "resolved": "https://registry.npmjs.org/flexsearch/-/flexsearch-0.6.32.tgz",
+ "integrity": "sha512-EF1BWkhwoeLtbIlDbY/vDSLBen/E5l/f1Vg7iX5CDymQCamcx1vhlc3tIZxIDplPjgi0jhG37c67idFbjg+v+Q=="
+ },
"flush-write-stream": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/flush-write-stream/-/flush-write-stream-1.1.1.tgz",
@@ -8717,6 +8722,25 @@
"micromatch": "^3.1.10"
}
},
+ "gatsby-plugin-local-search": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/gatsby-plugin-local-search/-/gatsby-plugin-local-search-1.1.1.tgz",
+ "integrity": "sha512-OU0IR0Gi6ExZ3bzB0j6pR1rnnBPNGh3BEoRDAfvDeP9+U9rqzrPV053cr+Ueq0snEnlisPXu+vIv9Hd04esPnw==",
+ "requires": {
+ "flexsearch": "^0.6.32",
+ "lodash.lowerfirst": "^4.3.1",
+ "lodash.pick": "^4.4.0",
+ "lunr": "^2.3.8",
+ "pascalcase": "^1.0.0"
+ },
+ "dependencies": {
+ "pascalcase": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-1.0.0.tgz",
+ "integrity": "sha512-BSExi0rRnCHReJys6NocaK+cfTXNinAegfWBvr0JD3hiaEG7Nuc7r0CIdOJunXrs8gU/sbHQ9dxVAtiVQisjmg=="
+ }
+ }
+ },
"gatsby-plugin-manifest": {
"version": "2.4.17",
"resolved": "https://registry.npmjs.org/gatsby-plugin-manifest/-/gatsby-plugin-manifest-2.4.17.tgz",
@@ -12703,6 +12727,11 @@
"resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz",
"integrity": "sha1-QVxEePK8wwEgwizhDtMib30+GOA="
},
+ "lodash.lowerfirst": {
+ "version": "4.3.1",
+ "resolved": "https://registry.npmjs.org/lodash.lowerfirst/-/lodash.lowerfirst-4.3.1.tgz",
+ "integrity": "sha1-3jx7EuAsZSSgBZwvbLfFxSZVoT0="
+ },
"lodash.map": {
"version": "4.6.0",
"resolved": "https://registry.npmjs.org/lodash.map/-/lodash.map-4.6.0.tgz",
@@ -12718,6 +12747,11 @@
"resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz",
"integrity": "sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4="
},
+ "lodash.pick": {
+ "version": "4.4.0",
+ "resolved": "https://registry.npmjs.org/lodash.pick/-/lodash.pick-4.4.0.tgz",
+ "integrity": "sha1-UvBWEP/53tQiYRRB7R/BI6AwAbM="
+ },
"lodash.throttle": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/lodash.throttle/-/lodash.throttle-4.1.1.tgz",
@@ -12908,6 +12942,11 @@
"yallist": "^2.0.0"
}
},
+ "lunr": {
+ "version": "2.3.8",
+ "resolved": "https://registry.npmjs.org/lunr/-/lunr-2.3.8.tgz",
+ "integrity": "sha512-oxMeX/Y35PNFuZoHp+jUj5OSEmLCaIH4KTFJh7a93cHBoFmpw2IoPs22VIz7vyO2YUnx2Tn9dzIwO2P/4quIRg=="
+ },
"magic-string": {
"version": "0.25.7",
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.7.tgz",
@@ -17027,6 +17066,14 @@
}
}
},
+ "react-use-flexsearch": {
+ "version": "0.1.1",
+ "resolved": "https://registry.npmjs.org/react-use-flexsearch/-/react-use-flexsearch-0.1.1.tgz",
+ "integrity": "sha512-UDRDB26HPcAo0gXNkUYYkcjoYCW4FSWr7Ich4adgVr7bqefJG7fnjlcqnwsKQkbZuteRLYzzox+1FKRTt3Z5vg==",
+ "requires": {
+ "flexsearch": "^0.6.22"
+ }
+ },
"react-virtualized-auto-sizer": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/react-virtualized-auto-sizer/-/react-virtualized-auto-sizer-1.0.2.tgz",
diff --git a/package.json b/package.json
index 13dfec4..1733519 100644
--- a/package.json
+++ b/package.json
@@ -19,6 +19,7 @@
"esm": "^3.2.25",
"gatsby": "^2.23.12",
"gatsby-image": "^2.4.12",
+ "gatsby-plugin-local-search": "^1.1.1",
"gatsby-plugin-manifest": "^2.4.17",
"gatsby-plugin-netlify-cms": "^4.3.9",
"gatsby-plugin-react-helmet": "^3.3.8",
@@ -36,11 +37,13 @@
"node-sass": "^4.14.1",
"prismjs": "^1.20.0",
"prop-types": "^15.7.2",
+ "query-string": "^6.13.1",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-flexbox-grid": "^2.1.2",
"react-github-btn": "^1.2.0",
- "react-helmet": "^6.1.0"
+ "react-helmet": "^6.1.0",
+ "react-use-flexsearch": "^0.1.1"
},
"devDependencies": {
"prettier": "2.0.5"
diff --git a/src/components/Article/Article.js b/src/components/Article/Article.js
index 37c22f1..da675e1 100644
--- a/src/components/Article/Article.js
+++ b/src/components/Article/Article.js
@@ -16,7 +16,7 @@ const Article = ({ data: { slug, keywords, title, image, description, category,
const { siteMetadata: { siteUrl } } = useSiteMetadataQuery()
return (
<>
-
Показано {edges.edges.length} из категории "{title}"
Показано {edges.edges.length} по тегу "{title}"