Skip to content

Commit a610b09

Browse files
authored
docs: include methods in search results again (#1692)
This moves the indexing config for elasticlunr search to only use MarkdownRemark nodes, since everything is being source as markdown files from `plugin-rest-endpoint-methods.js`. Now all of the information that was previously available for search indexing will be available in the frontmatter of each method's markdown file. I tried sourcing this information from the htmlAst and headings fields in the MarkdownRemark nodes, but it appears that gatsby-transformer-remark doesn't generate that information until it's queried for the first time, and the config portion for building the search index happens before that, so that was unavailable. Placing it in the frontmatter seemed like a good way to have it available during the build step without modifying the visible content of the documentation or figuring out how to force that information to build earlier and then parse an HTML AST for title and example snippets.
1 parent 80e87a0 commit a610b09

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

docs/gatsby-config.js

+5-15
Original file line numberDiff line numberDiff line change
@@ -74,21 +74,11 @@ module.exports = {
7474
// For any node of type MarkdownRemark, list how to resolve the fields` values
7575
MarkdownRemark: {
7676
title: node => node.frontmatter.title,
77-
slug: node => `#${node.fields.idName}`,
78-
type: node => "API"
79-
},
80-
OctokitApiGroup: {
81-
title: node => upperFirst(node.name),
82-
slug: node => `#${node.id}`,
83-
type: node => "API"
84-
},
85-
OctokitApiMethod: {
86-
name: node => node.name,
87-
scope: node => node.scope,
88-
route: node => `${node.method} ${node.url}`,
89-
method: node => `${node.example}`,
90-
slug: node => `#${node.id}`,
91-
type: node => "API method"
77+
name: node => node.frontmatter.name,
78+
slug: node => `#${node.frontmatter.scope ? node.frontmatter.scope + '-' : ''}${node.fields.idName}`,
79+
route: node => `${node.frontmatter.route}`,
80+
method: node => `${node.frontmatter.example}`,
81+
type: node => node.frontmatter.type || "API"
9282
}
9383
}
9484
}

0 commit comments

Comments
 (0)