· 1 min read

Code Syntax Highlighting In Nuxt

Update: This method is no longer used and I prefer to go with this approach

For displaying code blocks in a markdown editor I chose to use the package vue-markdown-highlight

In a normal vue app the code below would be imported in main.js In a nuxt app this is the way to do it:

1. Create a file in the plugins directory called highlight.js

import Vue from 'vue';
import 'highlight.js/styles/default.css';
import Highlight from 'vue-markdown-highlight';
Vue.use(Highlight);

2. In nuxt.config.js edit the plugins section

plugins: [{ src: '~/plugins/highlight.js', mode: 'client' }];

3. In the vue file where you intend to use highlight

<div v-html="content" v-highlight></div>
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.