· 1 min read

Code Syntax Highlighting For Markdown In Nuxt 2

In a previous blog post I mentioned how to add code syntax highlighting for a nuxt project.

Since then I have noticed a few issues and decided to abandon that approach and go with this one.

Import the package:

npm i --save markdown-it-highlightjs

In nuxt.config.js

 modules: ["@nuxtjs/markdownit"],
  markdownit: {
    injected: true,
    use: ["markdown-it-highlightjs"],
  },

And where I differ from the post by Samuel is to just link to the CDN link instead. Referencing the link within the node modules folder would not work for me.

    link: [
      {
        rel: "stylesheet",
        type: "text/css",
        href: "//unpkg.com/@highlightjs/[email protected]/styles/tomorrow-night-blue.min.css",
      },
    ],

To choose another colour style select a css file from the highlight.js github page and remember to end with .min.css

Back to Blog

Related Posts

View All Posts »
How to Connect to a DigitalOcean Managed Database When Your IP Address Changes

How to Connect to a DigitalOcean Managed Database When Your IP Address Changes

If you're working with a DigitalOcean managed database from your local machine, you've probably run into this frustrating scenario: everything works perfectly one day, then suddenly your database connection times out. The culprit? Your IP address changed, and it's no longer in the database's trusted sources list.

Paging In .Net Core with C# and Linq

Paging In .Net Core with C# and Linq

Almost every medium to large site requires some sort of paging through lists of information. The advantage of paging is that you only need to bring back a limited result set.