NotionX / react-notion-x

Fast and accurate React renderer for Notion. TS batteries included. ⚡️
https://react-notion-x-demo.transitivebullsh.it
MIT License
4.67k stars 544 forks source link

Code block highlight Golang not supported? #302

Open anriclee opened 2 years ago

anriclee commented 2 years ago

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

MahitMehta commented 1 year ago

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!