Code highlighting not working - Nuxt 3
See original GitHub issueEnvironment
- Operating System:
Linux
- Node Version:
v16.17.0
- Nuxt Version:
3.0.0-rc.9-27702110.abd5dc5
- Nitro Version:
0.5.0-27700766.92d711f
- Package Manager:
yarn@3.2.3
- Builder:
vite
- User Config:
preset
,target
,mode
,nitro
,runtimeConfig
,app
,css
,imports
,components
,build
,modules
,vueuse
,content
,experimental
,vite
,directus
- Runtime Modules:
@nuxtjs/tailwindcss
,nuxt-directus
,@nuxtjs/eslint-module@3.1.0
,unplugin-icons/nuxt
,@nuxtjs/svg@0.4.0
,@vueuse/nuxt@9.1.1
,@nuxt/content
,@pinia/nuxt
- Build Modules:
-
Reproduction
nuxt.config.js
// content
content: {
toc: {
depth: 2,
searchDepth: 2
},
highlight: {
// Theme used in all color schemes.
theme: 'github-light',
preload: ['diff', 'ts', 'js', 'css', 'java', 'groovy', 'sql', 'xml', 'json'],
}
},
page.vue
<template>
<ContentRenderer :value="post"/>`
</template>
<script setup>
const post = await queryContent("blog")
.where({slug: route.params.slug})
.findOne();
</script>
package.json
"@nuxt/content": "^2.0.1",
Describe the bug
Whatever I try, the code highlighting does not work and the document tree does not seem to get any additional classes attached.
I’m currently migrating my blog from Gridsome to Nuxt, so the markdown files are correct and already used in production.
Am I missing something?
Additional context
No response
Logs
No response
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:16 (7 by maintainers)
Top Results From Across the Web
why vs code syntax highlighting stop working - Stack Overflow
i use vue and vuex. i just realised that the syntax highlighting stops in the middle of the .js file. what could be...
Read more >nuxt-highlightjs - npm
Highlightjs code block styling and syntax highlighting for Nuxt 2. Latest version: 1.0.3, last published: 5 months ago.
Read more >Markdown - Nuxt Content
Code highlighting works both on ProseCode and ProseCodeInline . Read the API reference to configure or entirely disable syntax highlighting.
Read more >Ckeditor 5 syntax highlighting in nuxt - BlowStack
To make your code beautifully highlighted using ckeditor as a text editor you will have to use some of the available third party...
Read more >Using VS Code themes for your code blocks in Nuxt with Shiki
I'll be showing you how to set up Shiki for custom highlighting in your Nuxt Content site. For this one, I'll assume you...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@leopoldkristjansson By default Content module does not add background or border to code blocks. What are you referring as wrapper div is part of Nuxt Typography Theme which provide a nice styling for Prose components. You can also create your custom Prose component in
components/content
directory, See Docs@amit-chaudhary4 I think your issue is because you’re trying to use the shiki highlighter API directly, and in the wrong place. Check out the docs on @nuxt/content Configuration. I’m a bit behind on the status of edge-channel features, but last I checked,
highlighter
wasn’t a configurable property under thecontent.markdown
key path.If you need to implement custom syntax highlighting logic the easiest route is probably to create a server-side middleware or content transformer.