I try to create a plugin in nuxt3 that uses highligh.js and use it on my components. But I can't do it
I make this :
// @/plugins/highlight.js
import 'highlight.js/styles/stackoverflow-light.css'
import hljs from 'highlight.js/lib/core';
import json from 'highlight.js/lib/languages/json';
hljs.registerLanguage('json', json);
import 'highlight.js/styles/vs.css'
export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.vueApp.use(hljs)
})
I want to use like this :
// @/components/JSONView.vue
<template>
<highlightjs
language="json"
:code="myCode"
/>
</template>
<script setup>
const code = ref('{ "done": true }')
</script>
Thanks in advance
You can use the official Vue plugin from highlight Js
npm i @highlightjs/vue-plugin~/plugins/highlight.client.tsComponent usage
Tested and it works.