Skip to content

Commit

Permalink
chore(gatsby-plugin-mdx): Update "headings" instructions (#36593)
Browse files Browse the repository at this point in the history
  • Loading branch information
LekoArts authored Sep 12, 2022
1 parent e174fbb commit b1b83c1
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 4 deletions.
10 changes: 9 additions & 1 deletion examples/using-mdx/content/posts/blog-1.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,12 @@ Some GFM features like tables:

| Hello | World | | | |
|---------|-------|---|---|---|
| How are | you? | | | |
| How are | you? | | | |

## Heading Level Two

Some text

### Heading Level Three

Some more text
10 changes: 9 additions & 1 deletion examples/using-mdx/content/posts/blog-2.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,12 @@ You can use the Collapsible shortcode here because you provide it in the src/tem

You'll find content here!

</Collapsible>
</Collapsible>

## Heading Level Two

Some text

### Heading Level Three

Some more text
3 changes: 3 additions & 0 deletions examples/using-mdx/gatsby-config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* @type {import('gatsby').GatsbyConfig}
*/
module.exports = {
siteMetadata: {
title: `Using MDX example`,
Expand Down
12 changes: 11 additions & 1 deletion examples/using-mdx/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ const slugify = require(`@sindresorhus/slugify`)
const { compileMDXWithCustomOptions } = require(`gatsby-plugin-mdx`)
const { remarkHeadingsPlugin } = require(`./remark-headings-plugin`)

/**
* @type {import('gatsby').GatsbyNode['onCreateNode']}
*/
exports.onCreateNode = ({ node, actions }) => {
const { createNodeField } = actions
if (node.internal.type === `Mdx`) {
Expand All @@ -21,7 +24,10 @@ exports.onCreateNode = ({ node, actions }) => {
}
}

exports.createSchemaCustomization = async ({ getNode, getNodesByType, pathPrefix, reporter, cache, actions, schema }) => {
/**
* @type {import('gatsby').GatsbyNode['createSchemaCustomization']}
*/
exports.createSchemaCustomization = async ({ getNode, getNodesByType, pathPrefix, reporter, cache, actions, schema, store }) => {
const { createTypes } = actions

const headingsResolver = schema.buildObjectType({
Expand Down Expand Up @@ -53,6 +59,7 @@ exports.createSchemaCustomization = async ({ getNode, getNodesByType, pathPrefix
pathPrefix,
reporter,
cache,
store,
}
)

Expand Down Expand Up @@ -81,6 +88,9 @@ exports.createSchemaCustomization = async ({ getNode, getNodesByType, pathPrefix
])
}

/**
* @type {import('gatsby').GatsbyNode['createPages']}
*/
exports.createPages = async ({ graphql, actions, reporter }) => {
const { createPage } = actions

Expand Down
3 changes: 2 additions & 1 deletion packages/gatsby-plugin-mdx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ If you don't want to use the `frontmatter.title`, adjust what you input to `slug
const { compileMDXWithCustomOptions } = require(`gatsby-plugin-mdx`)
const { remarkHeadingsPlugin } = require(`./remark-headings-plugin`)
exports.createSchemaCustomization = async ({ getNode, getNodesByType, pathPrefix, reporter, cache, actions, schema }) => {
exports.createSchemaCustomization = async ({ getNode, getNodesByType, pathPrefix, reporter, cache, actions, schema, store }) => {
const { createTypes } = actions
const headingsResolver = schema.buildObjectType({
Expand Down Expand Up @@ -414,6 +414,7 @@ If you don't want to use the `frontmatter.title`, adjust what you input to `slug
pathPrefix,
reporter,
cache,
store,
}
)
Expand Down

0 comments on commit b1b83c1

Please sign in to comment.