content icon indicating copy to clipboard operation
content copied to clipboard

error for markdown files with empty body

Open stefanprobst opened this issue 1 year ago • 2 comments

Environment

  • Operating System: Linux
  • Node Version: v18.19.0
  • Nuxt Version: 3.10.1
  • CLI Version: 3.10.0
  • Nitro Version: 2.8.1
  • Package Manager: [email protected]
  • Builder: -
  • User Config: devtools, modules
  • Runtime Modules: @nuxt/[email protected]
  • Build Modules: -

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

stefanprobst avatar Feb 09 '24 19:02 stefanprobst

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

prazdevs avatar Feb 10 '24 22:02 prazdevs

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").

stefanprobst avatar Feb 11 '24 08:02 stefanprobst

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 Jul 18 '24 14:07 github-actions[bot]

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

github-actions[bot] avatar Aug 18 '24 01:08 github-actions[bot]