Skip to content

Commit 120c32e

Browse files
committed
Reintroduce tableOfContents
1 parent a5c6124 commit 120c32e

File tree

2 files changed

+16
-80
lines changed

2 files changed

+16
-80
lines changed

theme/gatsby-node.js

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,19 @@ exports.sourceNodes = ({ actions, schema }) => {
3434
order: {
3535
type: 'String!',
3636
},
37-
// tableOfContents: {
38-
// type: 'TocJson!',
39-
// resolve(source, args, context, info) {
40-
// const type = info.schema.getType(`Mdx`)
41-
// const mdxNode = context.nodeModel.getNodeById({
42-
// id: source.parent,
43-
// })
44-
// const resolver = type.getFields()['tableOfContents'].resolve
45-
// return resolver(mdxNode, {}, context, {
46-
// fieldName: 'tableOfContents',
47-
// })
48-
// },
49-
// },
37+
tableOfContents: {
38+
type: 'JSON!',
39+
resolve(source, args, context, info) {
40+
const type = info.schema.getType(`Mdx`)
41+
const mdxNode = context.nodeModel.getNodeById({
42+
id: source.parent,
43+
})
44+
const resolver = type.getFields()['tableOfContents'].resolve
45+
return resolver(mdxNode, {}, context, {
46+
fieldName: 'tableOfContents',
47+
})
48+
},
49+
},
5050
body: {
5151
type: 'String!',
5252
resolve(source, args, context, info) {
@@ -71,7 +71,7 @@ exports.sourceNodes = ({ actions, schema }) => {
7171
fields: {
7272
id: { type: `ID!` },
7373
data: {
74-
type: 'MenuItem!',
74+
type: 'JSON!',
7575
},
7676
},
7777
interfaces: [`Node`],
@@ -223,7 +223,7 @@ exports.onCreateNode = ({
223223
metaTitle: node.frontmatter.metaTitle || title,
224224
metaDescription: node.frontmatter.metaDescription || '',
225225
order: node.frontmatter.order || title,
226-
// tableOfContents: node.tableOfContents,
226+
tableOfContents: node.tableOfContents,
227227
rawBody: node.rawBody,
228228
}
229229

@@ -254,21 +254,6 @@ exports.createSchemaCustomization = ({ actions }) => {
254254
type AuthorJson implements Node {
255255
joinedAt: Date
256256
}
257-
258-
type MenuInfo implements Node {
259-
id: String!
260-
url: String!
261-
order: String!
262-
title: String!
263-
}
264-
265-
type MenuItem implements Node {
266-
id: String!
267-
label: String!
268-
info: MenuInfo
269-
items: [MenuItem!]!
270-
}
271-
272257
`
273258

274259
createTypes(typeDefs)

theme/src/components/Sidebar.tsx

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -22,56 +22,7 @@ export const Sidebar = ({ location, current }: SidebarProps) => {
2222
graphql`
2323
query MenuQuery {
2424
menu(id: { eq: "menu" }) {
25-
data {
26-
id
27-
label
28-
info {
29-
id
30-
url
31-
order
32-
title
33-
}
34-
items {
35-
id
36-
label
37-
info {
38-
id
39-
url
40-
order
41-
title
42-
}
43-
items {
44-
id
45-
label
46-
info {
47-
id
48-
url
49-
order
50-
title
51-
}
52-
items {
53-
id
54-
label
55-
info {
56-
id
57-
url
58-
order
59-
title
60-
}
61-
items {
62-
id
63-
label
64-
info {
65-
id
66-
url
67-
order
68-
title
69-
}
70-
}
71-
}
72-
}
73-
}
74-
}
25+
data
7526
}
7627
site {
7728
siteMetadata {

0 commit comments

Comments
 (0)