@primer/gatsby-theme-doctocat 4.6.2 → 4.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/gatsby-node.js +11 -0
- package/package.json +1 -1
- package/src/components/header.js +1 -1
- package/src/components/layout.js +2 -0
- package/src/use-search.js +24 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @primer/gatsby-theme-doctocat
|
|
2
2
|
|
|
3
|
+
## 4.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`a7749f9`](https://github.com/primer/doctocat/commit/a7749f9d44681e2eaa5b265d35767461a648e259) [#624](https://github.com/primer/doctocat/pull/624) Thanks [@camertron](https://github.com/camertron)! - Ability to add custom docs to search
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [`d03feaa`](https://github.com/primer/doctocat/commit/d03feaab9942485559e99da5525ccb34f1502a68) [#623](https://github.com/primer/doctocat/pull/623) Thanks [@emilybrick](https://github.com/emilybrick)! - - Add maxWidth: '1200' to the base layout container so that content widths are consistent across primer.style docs
|
|
12
|
+
|
|
13
|
+
## 4.6.3
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [`af1a0e1`](https://github.com/primer/doctocat/commit/af1a0e1bab8df4d241a3e1e760fe6924b887372f) [#621](https://github.com/primer/doctocat/pull/621) Thanks [@josepmartins](https://github.com/josepmartins)! - Fixes selected state when the path is `undefined`
|
|
18
|
+
|
|
3
19
|
## 4.6.2
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/gatsby-node.js
CHANGED
|
@@ -9,6 +9,17 @@ const mdx = require(`gatsby-plugin-mdx/utils/mdx`)
|
|
|
9
9
|
|
|
10
10
|
const CONTRIBUTOR_CACHE = new Map()
|
|
11
11
|
|
|
12
|
+
exports.createSchemaCustomization = async ({actions}) => {
|
|
13
|
+
const typeDefs = `
|
|
14
|
+
type CustomSearchDoc implements Node {
|
|
15
|
+
path: String!
|
|
16
|
+
title: String!
|
|
17
|
+
rawBody: String!
|
|
18
|
+
}
|
|
19
|
+
`
|
|
20
|
+
actions.createTypes(typeDefs)
|
|
21
|
+
}
|
|
22
|
+
|
|
12
23
|
exports.createPages = async ({graphql, actions}, themeOptions) => {
|
|
13
24
|
const repo = getPkgRepo(readPkgUp.sync().package)
|
|
14
25
|
|
package/package.json
CHANGED
package/src/components/header.js
CHANGED
|
@@ -156,7 +156,7 @@ function PrimerNavItems({siteMetadata, items, path, pathPrefix}) {
|
|
|
156
156
|
<UnderlineNav.Link
|
|
157
157
|
key={index}
|
|
158
158
|
href={item.url}
|
|
159
|
-
selected={item.url === siteMetadata.header.url + pathPrefix + path}
|
|
159
|
+
selected={item.url === siteMetadata.header.url + (pathPrefix || '') + (path || '')}
|
|
160
160
|
sx={{fontSize: 2, lineHeight: 'condensed'}}
|
|
161
161
|
>
|
|
162
162
|
{item.title}
|
package/src/components/layout.js
CHANGED
package/src/use-search.js
CHANGED
|
@@ -10,7 +10,7 @@ function useSearch(query) {
|
|
|
10
10
|
const workerRef = React.useRef()
|
|
11
11
|
|
|
12
12
|
const data = useStaticQuery(graphql`
|
|
13
|
-
{
|
|
13
|
+
query {
|
|
14
14
|
allMdx {
|
|
15
15
|
nodes {
|
|
16
16
|
fileAbsolutePath
|
|
@@ -26,20 +26,32 @@ function useSearch(query) {
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
+
|
|
30
|
+
allCustomSearchDoc {
|
|
31
|
+
nodes {
|
|
32
|
+
path
|
|
33
|
+
title
|
|
34
|
+
rawBody
|
|
35
|
+
}
|
|
36
|
+
}
|
|
29
37
|
}
|
|
30
38
|
`)
|
|
31
39
|
|
|
32
|
-
const list = React.useMemo(
|
|
33
|
-
(
|
|
34
|
-
|
|
35
|
-
path:
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
const list = React.useMemo(() => {
|
|
41
|
+
const results = data.allMdx.nodes.map(node => ({
|
|
42
|
+
path: ensureAbsolute(
|
|
43
|
+
path.join(node.parent.relativeDirectory, node.parent.name === 'index' ? '/' : node.parent.name)
|
|
44
|
+
),
|
|
45
|
+
title: node.frontmatter.title,
|
|
46
|
+
rawBody: node.rawBody
|
|
47
|
+
}))
|
|
48
|
+
|
|
49
|
+
if (data.allCustomSearchDoc.nodes) {
|
|
50
|
+
results.push(...data.allCustomSearchDoc.nodes)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return results
|
|
54
|
+
}, [data])
|
|
43
55
|
|
|
44
56
|
const [results, setResults] = React.useState(list)
|
|
45
57
|
|