Highlightjs code block styling and syntax highlighting for Nuxt 2
npm install nuxt-highlightjsnuxt-highlightjs dependency to your project
bash
npm install --save nuxt-highlightjs
`
2. Add nuxt-highlightjs to the modules section of nuxt.config.js
`js
modules: [
// Simple Usage
'nuxt-highlightjs',
// With Options
['nuxt-highlightjs', {
// Module Options
}]
],
`
Usage
In your .vue template:
`html
console.log('Hello World')
console.log('Hello World')
`
The example above uses javascript highlighting, you can change the class on the code element to any of the supported languages to set the highlighting.
Module Options
style
- Type: string
- Default: default
Set the highlight.js theme
See list of available style options
`js
modules: [
// With Options
['nuxt-highlightjs', {
style: 'obsidian'
}]
],
``