Nuxt Content ContentRenderer not rendering Markdown
For some reason this is not rendering a markdown file in Markdown, it's just plain text <ContentRenderer v-if="page" :value="page" />
18 Replies
Hi @nathanr. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
It looks like you're having an issue with the
<ContentRenderer>
component not properly rendering your Markdown content. This is a common issue that can happen for several reasons.
Based on the knowledge sources, here are some potential solutions:
1. Make sure you have the correct setup
First, ensure you have properly set up Nuxt Content in your project:
And that you have a proper content configuration:
2. Check your query and component usage
Make sure you're correctly querying the content and using the ContentRenderer component:
3. Add typography styling
If your Markdown is rendering as plain text, you might be missing the typography styling. For Tailwind users, install the typography plugin:
Then add it to your Tailwind config:
And wrap your ContentRenderer with a prose class:
4. Check the prose prop
The ContentRenderer
component has a prose
prop that controls whether to render Prose components instead of HTML tags. Try setting it explicitly:
For landing pages or non-prose content, you might want to set it to false:
5. Verify your Markdown file
Make sure your Markdown file is properly formatted and doesn't have any syntax issues.
If you're still having issues, it might be helpful to check the console for any errors and verify that your content is being properly loaded by logging the page
value.
Nuxt Content documentation provides more details about the ContentRenderer component and its usage.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@243051127904534528> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
@kapa.ai tailwind.config.ts is outdated now
Let me check the knowledge base for you again. One moment! :books:
----------------------
You're right! With the latest versions of Nuxt UI and Nuxt Content, the approach to Tailwind CSS configuration has changed significantly, especially with Tailwind CSS v4.
Tailwind CSS v4 in Nuxt: CSS-first approach
Tailwind CSS v4 now uses a CSS-first configuration approach instead of the JavaScript-based configuration in
tailwind.config.ts
. This is a major change when working with Nuxt UI v3 and Nuxt Content v3.
New approach:
1. Create a CSS file (typically assets/css/main.css
) and import it in your Nuxt config:
2. Import this CSS file in your Nuxt config:
Key changes:
- The @theme
directive replaces the theme.extend
key from your old tailwind.config.ts
- The @source
directive is crucial for Tailwind to detect classes in markdown files with Nuxt Content
- If you're using Nuxt UI Pro, you'd import @nuxt/ui-pro
instead of @nuxt/ui
Nuxt UI Theme documentation provides more details about this new approach to theming.
This change is part of the broader migration to Nuxt UI v3 and Nuxt Content v3, which includes many other breaking changes to components, APIs, and styling approaches.
Would you like more specific guidance on migrating your particular Tailwind configuration to this new approach?
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@243051127904534528> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
Would you be able to provide more information, such as the
package.json
, nuxt.config.ts
, and so on?Ok thanks! And the file in which you have the ContentRenderer and your content.config.ts?
@HugoRCD Thanks for looking, I was actually following how you have achieved this on your blog/ example Nuxt Content page
No worries 😁 You just forgot the script part with the queryCollection didn't you?
Sorry I took it out the message as it wasn't formatting properly
The thing is the page is loading with the right meta data, I can search and query etc, it's just not rendering markdown as I'd have expected it
How would you like the markdown to be rendered?
Nothing too crazy, just '#' for headers, and '-' for lists, as well as '1.' working for numbered lists too
Am I missing this? https://content.nuxt.com/docs/components/prose
These styles are generated by NuxtUI Pro, which overrides all proses components!
If you want to have a relatively simple "similar" style, you can use the tailwind typography plugin: https://github.com/tailwindlabs/tailwindcss-typography
GitHub
GitHub - tailwindlabs/tailwindcss-typography: Beautiful typographic...
Beautiful typographic defaults for HTML you don't control. - tailwindlabs/tailwindcss-typography
Ah yes, I think I use this before, but didn't know how to customise it, would you say nuxt pro is better?
I'm a bit biased but yes, UI Pro will be more easily customizable and consistent with the theme of your app, you'll have all the features like '#' on headers and scroll that will be done the right way, etc. ... Then accessorily all the rest of the components and templates! 😁