@@ -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 )
0 commit comments