Merge pull request #379 from timlrx/refactor/simplify-mdx

remove redundant frontmatter parsing
This commit is contained in:
Timothy 2022-02-06 21:11:03 +08:00 committed by GitHub
commit 609623d405
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -56,13 +56,11 @@ export async function getFileBySlug(type, slug) {
let toc = []
// Parsing frontmatter here to pass it in as options to rehype plugin
const { data: frontmatter } = matter(source)
const { code } = await bundleMDX({
const { code, frontmatter } = await bundleMDX({
source,
// mdx imports can be automatically source from the components directory
cwd: path.join(root, 'components'),
xdmOptions(options) {
xdmOptions(options, frontmatter) {
// this is the recommended way to add custom remark/rehype plugins:
// The syntax might look weird, but it protects you in case we add/remove
// plugins in the future.