nuxt / content

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

error for markdown files with empty body #2551

Open stefanprobst opened 4 months ago

stefanprobst commented 4 months ago

Environment

Reproduction

https://github.com/stefanprobst/issue-nuxt-content

Describe the bug

for a markdown file with an empty body (see this one in the issue repro), i get the following error:

{
  "message": "You should use slots with <ContentRenderer>",
  "value": {
    "_path": "/",
    "_dir": "",
    "_draft": false,
    "_partial": false,
    "_locale": "",
    "title": "test",
    "description": "",
    "body": {
      "type": "root",
      "children": [],
      "toc": {
        "title": "",
        "searchDepth": 2,
        "depth": 2,
        "links": []
      }
    },
    "_type": "markdown",
    "_id": "content:index.md",
    "_source": "content",
    "_file": "index.md",
    "_extension": "md"
  },
  "excerpt": false,
  "tag": "div"
}

instead, i would expect an empty div.

Additional context

No response

Logs

No response

prazdevs commented 4 months ago

Since you are using ContentRenderer you need to provide an #empty slot to fallback in case the markdown body is empty: https://content.nuxt.com/components/content-renderer#slots

stefanprobst commented 4 months ago

thanks for pointing to that section in the docs!

however, the wording is a bit ambiguous and it's still not 100% clear to me whether i must provide an #empty slot, or if this is a bug ("The empty slot can be used to display a default content when the document is empty").