Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error for markdown files with empty body #2551

Open
stefanprobst opened this issue Feb 9, 2024 · 2 comments
Open

error for markdown files with empty body #2551

stefanprobst opened this issue Feb 9, 2024 · 2 comments

Comments

@stefanprobst
Copy link
Contributor

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: pnpm@8.14.1
  • Builder: -
  • User Config: devtools, modules
  • Runtime Modules: @nuxt/content@2.12.0
  • 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

@prazdevs
Copy link

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
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants