Remix - remix.config.js - How to configure rehype-highlight and register an additional language for highlighting?

Viewed 78

In remix.config.js I have the following code

 mdx: async (filename) => {
    const [rehypeHighlight] = await Promise.all([
      import("rehype-highlight").then((module) => module.default),
    ]);
    return {
      rehypePlugins: [rehypeHighlight],
    };
  },

How can I register another language (GraphQL) to rehype-highlight?

1 Answers

In the meantime I have found out. Here is the modified code to register another language in case someone else can't see the forest for the trees either :)

const gql = require( "highlight.js/lib/languages/graphql" );

module.exports = {

//Other configuration settings have been omitted for clarity...

 mdx: async filename => {
   const [rehypeHighlight] = await Promise.all([
     import("rehype-highlight").then(mod => mod.default),
   ]);
   return {
     rehypePlugins: [
       [rehypeHighlight, { languages: {gql} }]
     ]
   }
 }

};
Related