Add ability to load plugins

This commit is contained in:
Marcus Blättermann 2022-11-13 16:31:26 +01:00
parent 790e03f900
commit aea5496788
No known key found for this signature in database
GPG Key ID: A1E1F04008AC450D
3 changed files with 13 additions and 1 deletions

View File

@ -1,8 +1,11 @@
import MDX from '@next/mdx'
import remarkPlugins from './plugins/index.mjs'
const withMDX = MDX({
extension: /\.mdx?$/,
options: {
remarkPlugins,
providerImportSource: '@mdx-js/react',
},
experimental: {

View File

@ -4,6 +4,7 @@ import fs from 'fs'
import { MDXRemote, MDXRemoteSerializeResult } from 'next-mdx-remote'
import path from 'path'
import Layout from '../components/layout'
import remarkPlugins from '../plugins/index.mjs'
type PropsPage = {
mdx: MDXRemoteSerializeResult
@ -43,7 +44,12 @@ export const getStaticProps: GetStaticProps<PropsPage, ParsedUrlQuery> = async (
slug: args.params.slug,
mdx: await serialize(
fs.readFileSync(path.join('docs', args.params.slug + '.mdx'), 'utf-8'),
{ parseFrontmatter: true }
{
parseFrontmatter: true,
mdxOptions: {
remarkPlugins,
},
}
),
},
}

View File

@ -0,0 +1,3 @@
const remarkPlugins = []
export default remarkPlugins