It's almost the same as gatsby-remark-slug yet it uses speakingurl instead of github-slugger for proper slugs on pages in languages other than English.
yarn add -D gatsby-remark-lang-slug
# or
npm i -D gatsby-remark-lang-slug
// gatsby-config.js
{
resolve: `gatsby-plugin-mdx`,
options: {
gatsbyRemarkPlugins: [
`gatsby-remark-lang-slug`,
]
}
}
It expects the language to be set as node field lang
using createNodeField
in onCreateNode
hook.
// gatsby-node.js
exports.onCreateNode = ({ node, actions: { createNodeField } }) => {
createNodeField({
node,
name: `lang`,
value: `de`,
})
}
It'll default to en
(English) if no lang has been set.
Please check out speakingurl's list of supported languages
Maybe add support for custom id's like ### My Great Heading {#custom-id}
as remark-heading-id does