@primer/gatsby-theme-doctocat 4.6.3 → 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 CHANGED
@@ -1,5 +1,15 @@
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
+
3
13
  ## 4.6.3
4
14
 
5
15
  ### 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primer/gatsby-theme-doctocat",
3
- "version": "4.6.3",
3
+ "version": "4.7.0",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "scripts": {
@@ -82,6 +82,8 @@ function Layout({children, pageContext, path}) {
82
82
  justifyContent: 'center',
83
83
  flexDirection: 'row-reverse',
84
84
  display: 'flex',
85
+ maxWidth: '1200px',
86
+ mx: 'auto',
85
87
  width: '100%',
86
88
  p: [4, 5, 6, 7]
87
89
  }}
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
- data.allMdx.nodes.map(node => ({
35
- path: ensureAbsolute(
36
- path.join(node.parent.relativeDirectory, node.parent.name === 'index' ? '/' : node.parent.name)
37
- ),
38
- title: node.frontmatter.title,
39
- rawBody: node.rawBody
40
- })),
41
- [data]
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