content icon indicating copy to clipboard operation
content copied to clipboard

ContentRenderer doesn't work

Open buditanrim opened this issue 1 year ago • 4 comments

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 <ContentRenderer> doesn't return anything. Question: What component can I use to render the content from the markdown?

buditanrim avatar Dec 24 '23 03:12 buditanrim

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.

AssetCEO avatar Dec 26 '23 03:12 AssetCEO

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

buditanrim avatar Dec 27 '23 10:12 buditanrim

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.

code4reason avatar Jan 02 '24 22:01 code4reason

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] avatar Aug 20 '24 01:08 github-actions[bot]