@primer/gatsby-theme-doctocat 4.6.3 → 4.7.1
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/layout.js +4 -1
- 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.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`ce79030`](https://github.com/primer/doctocat/commit/ce790304dce82ce99f536d474e384ed341db7103) [#628](https://github.com/primer/doctocat/pull/628) Thanks [@emilybrick](https://github.com/emilybrick)! - - Add withPrefix to breadcrumbs
|
|
8
|
+
|
|
9
|
+
## 4.7.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [`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
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [`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
|
|
18
|
+
|
|
3
19
|
## 4.6.3
|
|
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/layout.js
CHANGED
|
@@ -15,6 +15,7 @@ import StorybookLink from './storybook-link'
|
|
|
15
15
|
import FigmaLink from './figma-link'
|
|
16
16
|
import TableOfContents from './table-of-contents'
|
|
17
17
|
import navItems from '../nav.yml'
|
|
18
|
+
import {withPrefix} from 'gatsby'
|
|
18
19
|
|
|
19
20
|
const getPageAncestry = (url, object) => {
|
|
20
21
|
const result = []
|
|
@@ -82,6 +83,8 @@ function Layout({children, pageContext, path}) {
|
|
|
82
83
|
justifyContent: 'center',
|
|
83
84
|
flexDirection: 'row-reverse',
|
|
84
85
|
display: 'flex',
|
|
86
|
+
maxWidth: '1200px',
|
|
87
|
+
mx: 'auto',
|
|
85
88
|
width: '100%',
|
|
86
89
|
p: [4, 5, 6, 7]
|
|
87
90
|
}}
|
|
@@ -110,7 +113,7 @@ function Layout({children, pageContext, path}) {
|
|
|
110
113
|
{breadcrumbData.length > 1 ? (
|
|
111
114
|
<Breadcrumbs sx={{mb: 4}}>
|
|
112
115
|
{breadcrumbData.map(item => (
|
|
113
|
-
<Breadcrumbs.Item key={item.url} href={item.url} selected={path === item.url}>
|
|
116
|
+
<Breadcrumbs.Item key={item.url} href={withPrefix(item.url)} selected={path === item.url}>
|
|
114
117
|
{item.title}
|
|
115
118
|
</Breadcrumbs.Item>
|
|
116
119
|
))}
|
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
|
|