react-notion-x icon indicating copy to clipboard operation
react-notion-x copied to clipboard

Code block highlight Golang not supported?

Open anriclee opened this issue 3 years ago • 1 comments
trafficstars

Description

Code block highlight Golang not supported?

Notion Test Page ID

https://www.notion.so/anriclee/Adding-HTTP-response-headers-to-a-Netlify-static-website-61e28b5d902d464dbf199047d1fb7dda

image

anriclee avatar Jun 08 '22 05:06 anriclee

At the top of your file where you import the Code component, add the following additions.

const Code = dynamic(
    () => import('react-notion-x/build/third-party/code').then(async (m) => {
        await Promise.all([
            import('prismjs/components/prism-go.js'), // this line imports go syntax highlighting 
        ])
        return m.Code as any
    }),
)

If you would like to add support for other programming languages, just provide more imports in the Promise.all and change the import language name from prism-go.js to prism-[Language].

Hope this helps!

MahitMehta avatar Aug 26 '22 03:08 MahitMehta