next-contentlayer icon indicating copy to clipboard operation
next-contentlayer copied to clipboard

Is it possible to add syntax coloring?

Open cpmooney opened this issue 2 years ago • 3 comments

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 avatar Jul 29 '23 23:07 cpmooney

This pull request solves the problem:

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

Someone should probably merge that . . .

cpmooney avatar Jul 30 '23 17:07 cpmooney

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

faiqali1 avatar Sep 12 '23 17:09 faiqali1

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

michal-weglarz avatar Dec 13 '23 14:12 michal-weglarz