Skip to content

How to use remark-gfm plugin with compileMdx function #434

Closed Answered by sdorra
suryaashish-tyke asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @suryaashish-tyke, sorry i've missed your post. You can use remark plugins with mdx like that:

import { defineCollection, defineConfig } from "@content-collections/core";
import { compileMDX } from "@content-collections/mdx";
import remarkGfm from "remark-gfm";

const posts = defineCollection({
  name: "posts",
  directory: "content/posts",
  include: "*.mdx",
  schema: (z) => ({
    title: z.string(),
    summary: z.string(),
    date: z.coerce.date(),
    author: z.string(),
  }),
  transform: async (document, context) => {
    const mdx = await compileMDX(context, document, {
      remarkPlugins: [remarkGfm]
    });
    return {
      ...document,
      mdx,
    };
  },
});

export d…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@suryaashish-tyke
Comment options

@suryaashish-tyke
Comment options

Answer selected by suryaashish-tyke
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants