@@ -3,6 +3,8 @@ const readPkgUp = require('read-pkg-up')
3
3
const getPkgRepo = require ( 'get-pkg-repo' )
4
4
const axios = require ( 'axios' )
5
5
const uniqBy = require ( 'lodash.uniqby' )
6
+ const extractExports = require ( `gatsby-plugin-mdx/utils/extract-exports` )
7
+ const mdx = require ( `gatsby-plugin-mdx/utils/mdx` )
6
8
7
9
const CONTRIBUTOR_CACHE = new Map ( )
8
10
@@ -14,12 +16,7 @@ exports.createPages = async ({graphql, actions}, themeOptions) => {
14
16
allMdx {
15
17
nodes {
16
18
fileAbsolutePath
17
- frontmatter {
18
- title
19
- status
20
- source
21
- additionalContributors
22
- }
19
+ rawBody
23
20
tableOfContents(maxDepth: 3)
24
21
parent {
25
22
... on File {
@@ -63,6 +60,11 @@ exports.createPages = async ({graphql, actions}, themeOptions) => {
63
60
contributors = await fetchContributors ( repo , fileRelativePath , process . env . GITHUB_TOKEN )
64
61
}
65
62
63
+ // Copied from gatsby-plugin-mdx (https://git.io/JUs3H)
64
+ // as a workaround for https://github.com/gatsbyjs/gatsby/issues/21837
65
+ const code = await mdx ( node . rawBody )
66
+ const { frontmatter} = extractExports ( code )
67
+
66
68
actions . createPage ( {
67
69
path : pagePath ,
68
70
component : node . fileAbsolutePath ,
@@ -74,7 +76,7 @@ exports.createPages = async ({graphql, actions}, themeOptions) => {
74
76
// for us here, and does on the first build,
75
77
// but when HMR kicks in the frontmatter is lost.
76
78
// The solution is to include it here explicitly.
77
- frontmatter : node . frontmatter ,
79
+ frontmatter,
78
80
} ,
79
81
} )
80
82
} ) ,
0 commit comments