-
Notifications
You must be signed in to change notification settings - Fork 272
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(next): add gatsby-plugin-local-search (#1464)
* feat(next): add gatsby-plugin-local-search remove gatsby-plugin-lunr * feat(next): add gatsby-plugin-local-search remove gatsby-plugin-lunr * feat: add path * chore: remove old code * chore: clean up code * chore: cleanup * feat: fix tabs * feat: create search config file
- Loading branch information
1 parent
ed9d65f
commit cdee553
Showing
7 changed files
with
1,692 additions
and
1,495 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
packages/gatsby-theme-carbon/config/local-search-options.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
const defaultLocalSearchOptions = { | ||
// A unique name for the search index. This should be descriptive of | ||
// what the index contains. This is required. | ||
name: 'pages', | ||
|
||
// Set the search engine to create the index. This is required. | ||
// The following engines are supported: flexsearch, lunr | ||
engine: 'lunr', | ||
|
||
// Provide options to the engine. This is optional and only recommended | ||
// for advanced users. | ||
// | ||
// Note: Only the flexsearch engine supports options. | ||
engineOptions: 'default', | ||
|
||
// GraphQL query used to fetch all data for the search index. This is | ||
// required. | ||
query: ` | ||
{ | ||
allMdx { | ||
nodes { | ||
id | ||
frontmatter { | ||
description | ||
title | ||
} | ||
body | ||
internal { | ||
contentFilePath | ||
} | ||
} | ||
} | ||
} | ||
`, | ||
|
||
// Field used as the reference value for each document. | ||
// Default: 'id'. | ||
ref: 'id', | ||
|
||
// List of keys to index. The values of the keys are taken from the | ||
// normalizer function below. | ||
// Default: all fields | ||
index: ['title', 'body'], | ||
|
||
// List of keys to store and make available in your UI. The values of | ||
// the keys are taken from the normalizer function below. | ||
// Default: all fields | ||
store: ['id', 'description', 'title', 'path'], | ||
|
||
// Function used to map the result from the GraphQL query. This should | ||
// return an array of items to index in the form of flat objects | ||
// containing properties to index. The objects must contain the `ref` | ||
// field above (default: 'id'). This is required. | ||
normalizer: ({ data }) => | ||
data.allMdx.nodes.map((node) => ({ | ||
id: node.id, | ||
description: node.frontmatter.description, | ||
title: node.frontmatter.title, | ||
body: node.body, | ||
path: node.internal.contentFilePath, | ||
})), | ||
}; | ||
export default defaultLocalSearchOptions; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.