Skip to content

Commit ebcb730

Browse files
committed
Add elasticlunar-search plugin
1 parent b463b8a commit ebcb730

File tree

4 files changed

+44
-4
lines changed

4 files changed

+44
-4
lines changed

README.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ module.exports = {
4747
title: "Title",
4848
author: "Author",
4949
description: "Description",
50-
siteUrl: "https://your.site.url"
50+
siteUrl: "https://your.site.url",
5151
},
5252
plugins: [
5353
{
5454
resolve: `@committed/gatsby-theme-docs`,
55-
options: {}
56-
}
57-
]
55+
options: {},
56+
},
57+
],
5858
};
5959
```
6060

@@ -66,6 +66,16 @@ gatsby develop
6666

6767
Visit `http://localhost:8000/` to view the site.
6868

69+
Full text search is provided, but you MUST before a clean first to reindex the content:
70+
71+
```bash
72+
gatsby clean
73+
# Then:
74+
gatsby build
75+
# Or
76+
gatbsy develop
77+
```
78+
6979
For full instructions see the [live demo](https://committed.software/theme).
7080

7181
## 🤖 SEO friendly

theme/gatsby-config.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,23 @@ module.exports = ({
4040
`gatsby-plugin-material-ui`,
4141
`gatsby-plugin-react-helmet`,
4242
`gatsby-plugin-sharp`,
43+
// Add search
44+
{
45+
resolve: `@gatsby-contrib/gatsby-plugin-elasticlunr-search`,
46+
options: {
47+
fields: [`title`, `description`, `content`],
48+
resolvers: {
49+
Docs: {
50+
title: (node) => node.title,
51+
description: (node) => node.metaDescription,
52+
// TODO: This is the full raw body, including front matter
53+
content: (node) => node.rawBody,
54+
slug: (node) => node.slug,
55+
},
56+
},
57+
// TODO: Optional filter here, which would be useful for drafts?
58+
},
59+
},
4360
{
4461
resolve: `gatsby-plugin-layout`,
4562
options: {

theme/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"@material-ui/icons": "^4.9.1",
3737
"@mdx-js/mdx": "^1.6.1",
3838
"@mdx-js/react": "^1.6.1",
39+
"@gatsby-contrib/gatsby-plugin-elasticlunr-search": "^2.3.0",
3940
"gatsby-plugin-layout": "^1.3.0",
4041
"gatsby-plugin-material-ui": "^2.1.8",
4142
"gatsby-plugin-mdx": "^1.2.4",

yarn.lock

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -957,6 +957,13 @@
957957
resolved "https://registry.yarnpkg.com/@emotion/hash/-/hash-0.8.0.tgz#bbbff68978fefdbe68ccb533bc8cbe1d1afb5413"
958958
integrity sha512-kBJtf7PH6aWwZ6fka3zQ0p6SBYzx4fl1LoZXE2RrnYST9Xljm7WfKJrU4g/Xr3Beg72MLrp1AWNUmuYJTL7Cow==
959959

960+
"@gatsby-contrib/gatsby-plugin-elasticlunr-search@^2.3.0":
961+
version "2.3.0"
962+
resolved "https://registry.yarnpkg.com/@gatsby-contrib/gatsby-plugin-elasticlunr-search/-/gatsby-plugin-elasticlunr-search-2.3.0.tgz#af79021e6e3e6ca5d7a0b47b49dbfd196fa4ad1a"
963+
integrity sha512-ZClnKcMFzCRJMQhA1pq8OmRJtkUXNqYlzVIxhJpmk3MwskEU2C7Tl0nzdv++5GNbdG3ud9RdL7vLbDeg3sfP0Q==
964+
dependencies:
965+
elasticlunr "^0.9.5"
966+
960967
961968
version "2.1.4"
962969
resolved "https://registry.yarnpkg.com/@hapi/address/-/address-2.1.4.tgz#5d67ed43f3fd41a69d4b9ff7b56e7c0d1d0a81e5"
@@ -4999,6 +5006,11 @@ [email protected]:
49995006
resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d"
50005007
integrity sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=
50015008

5009+
elasticlunr@^0.9.5:
5010+
version "0.9.5"
5011+
resolved "https://registry.yarnpkg.com/elasticlunr/-/elasticlunr-0.9.5.tgz#65541bb309dddd0cf94f2d1c8861b2be651bb0d5"
5012+
integrity sha1-ZVQbswnd3Qz5Ty0ciGGyvmUbsNU=
5013+
50025014
electron-to-chromium@^1.3.247, electron-to-chromium@^1.3.413:
50035015
version "1.3.427"
50045016
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.427.tgz#ea43d02908a8c71f47ebb46e09de5a3cf8236f04"

0 commit comments

Comments
 (0)