content: ContentDoc with path does not find content

Environment

Nuxt CLI v3.0.0-rc.3-27550969.a4a3cff 12:03:02 RootDir: /sandbox 12:03:05 Nuxt project info: 12:03:05


  • Operating System: Linux
  • Node Version: v14.18.1
  • Nuxt Version: 3.0.0-rc.3-27550969.a4a3cff
  • Package Manager: yarn@1.22.17
  • Builder: vite
  • User Config: modules
  • Runtime Modules: @nuxt/content@2.0.0, @nuxt/ui@0.1.1-27555426.2ead323
  • Build Modules: -

Reproduction

https://codesandbox.io/s/nuxt3-contentv2-blog-demo-zokde1

Describe the bug

I want to use ContentDoc to query blog posts under content/blog by specifying path="/blog" in ContentDoc component.

If I enter <BASE_URL>/blog/my-article I always see the fallback code inside the #not-found slot instead of the index.md located at that path.

Additional context

No response

Logs

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 16 (4 by maintainers)

Most upvoted comments

Oh. I am using “@nuxt/content”: “^2.12.1” and still encountering a similar error.

@CodyBontecou In your example, you have to use <ContentDoc path="/" />, to get the content from the base content/ directory. [...slug].vue tries takes the default path where it resides, so it looks for Markdown in content/blog/.


Stackblitz does fail to find /, because there is no such path, try adding /blog/ to the url.


EDIT:

I played around a bit… I change the path in the index.md from /about (which obviously does not exist) to /blog/about and click on the link, it does nothing but giving back the /blog/ contents again. 🤔

Still getting this error

Hello @Mokkapps 🙂

This PR should resolve the issue: https://github.com/nuxt/content/pull/1143

Thanks for reporting the bug!

For me. It’s worked in development mode. but not working in production mode

Hey @nobkd that seems to fix my immediate issue, thank you.