nuxt / content

The file-based CMS for your Nuxt application, powered by Markdown and Vue components.
https://content.nuxt.com
MIT License
3.13k stars 627 forks source link

ContentRenderer doesn't work #2477

Closed buditanrim closed 1 month ago

buditanrim commented 10 months ago

Hello. everyone. I'm a bit confused when following the documentation

Given I have a markdown file:

 /content/article/design.md
---
title: How to design
year: 2023
---
The content of this markdown
In my /pages/article/[...slug].vue 

<template>
  <main>
    <ContentDoc>
      <template #default="{ doc }">
        <p>{{ doc.title }}</p>
        <p>{{ doc.year }}</p>
        <ContentRenderer :value="doc"/>
      </template>
    </ContentDoc>
  </main>
</template>

Problem: The title and year is rendered. But the doesn't return anything. Question: What component can I use to render the content from the markdown?

AssetCEO commented 10 months ago

I have tried your code, and it works fine. However, you can also try this: In /pages/article/[...slug].vue

    <ContentDoc v-slot="{ doc }">
      <article>
        <h1>{{ doc.title }}</h1>
        <p>{{ doc.year }}</p>
        <ContentRenderer :value="doc" />
      </article>
    </ContentDoc>

You can remove <article> tag, if it doesn't match your html structure.

buditanrim commented 10 months ago

Hello, I found that NuxtLayout created this issue; I'll provide more information soon. Still trying to wrap my head around the issue

code4reason commented 10 months ago

I experienced a renderproblem with links in Markdown files in a Nuxt 3 app with Nuxt Content v2. They rendered as plain text and was not clickable. Tried different browsers, incognito, deleted node cache, node_modules, .nuxt. Then i found this issue and removed NuxtLayout from my app.vue file. Then my links in markdown files worked. No solution, but a similar problem i guess? BTW, i upgraded NUXT, Vue, and Nuxt Content to latest versions.

github-actions[bot] commented 2 months ago

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] commented 1 month ago

This issue was closed because it has been stalled for 30 days with no activity.