shadcn / next-contentlayer

A template with Next.js 13 app dir, Contentlayer, Tailwind CSS and dark mode.
https://next-contentlayer.vercel.app
678 stars 91 forks source link

Is it possible to add syntax coloring? #16

Open cpmooney opened 1 year ago

cpmooney commented 1 year ago

Is it possible to enable syntax coloring in this example?

I installed rehype-highlight and followed https://www.contentlayer.dev/docs/reference/source-files/make-source-a5ba4922#mdx to get this:

export default makeSource({
  contentDirPath: "./content",
  documentTypes: [Post, Page],
  mdx: {
    rehypePlugins: [highlight],
  }
})

This has not worked for me so there must be more involved. Any idea about what that might be?

cpmooney commented 1 year ago

This pull request solves the problem:

https://github.com/shadcn/next-contentlayer/pull/1

Someone should probably merge that . . .

faiqali1 commented 1 year ago

Alternatively, I really like RehypePrettyCode Great support for line highlighting and other thing deffo worth a look

michal-weglarz commented 9 months ago

@cpmooney Rehype Pretty Code seems to be working for me without an issue.