nuxt / content

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

How to render excerpt without lost bindings from frontmatter? #2768

Closed 7iomka closed 2 months ago

7iomka commented 2 months ago

Environment


Reproduction

https://stackblitz.com/edit/github-yzzmyf?file=pages%2Findex.vue,content%2Fprojects%2Fproj1.md

Describe the bug

If we try to use ContentRendererMarkdown for some field of ContentDoc with type of ParsedContent or it partial, we see that data-bindings from frontmatter is broken, and all variables becomes strings values, and we see warnings for this in console as well. So, how to render the parts of data with ContentRendererMarkdown without this behavior? Or this is expected?

Additional context

No response

Logs

No response

farnabaz commented 2 months ago

Just pass data prop to markdown renderer.

In your case, pass doc as data:

<ContentRendererMarkdown v-if="doc.excerpt" :value="doc.excerpt" :data="doc"/>
7iomka commented 2 months ago

Just pass data prop to markdown renderer.

In your case, pass doc as data:

<ContentRendererMarkdown v-if="doc.excerpt" :value="doc.excerpt" :data="doc"/>

Wow - thanks! From the docs this is very unclear, because I don't fount any example like that.

farnabaz commented 2 months ago

Indeed it is not clear in docs. Feel free to drop a PR to update docs if you want to :)