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

ContentDoc with path does not find content #1142

Closed
Mokkapps opened this issue May 25, 2022 · 16 comments
Closed

ContentDoc with path does not find content #1142

Mokkapps opened this issue May 25, 2022 · 16 comments

Comments

@Mokkapps
Copy link

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

@Atinux
Copy link
Member

Atinux commented May 25, 2022

I think what you want to do is to use to show the posts in the blog/[...slug].vue pas

@Mokkapps
Copy link
Author

I think what you want to do is to use to show the posts in the blog/[...slug].vue pas

I see the same behavior with blog/[...slug].vue, see https://codesandbox.io/s/nuxt3-contentv2-blog-demo-with-slug-15pg83

@Tahul
Copy link
Contributor

Tahul commented May 25, 2022

Hello @Mokkapps 🙂

This PR should resolve the issue: #1143

Thanks for reporting the bug!

@R0N1n-dev
Copy link

So what is the actual fix for this, still not getting it

@Mokkapps
Copy link
Author

Mokkapps commented Jun 8, 2022

So what is the actual fix for this, still not getting it

Use "@nuxt/content": "^2.0.1" and it works ;-)

@Mokkapps Mokkapps closed this as completed Jun 8, 2022
@zdravkov
Copy link

zdravkov commented Nov 6, 2022

The error could also appear if you accidentally place the 'content' under another directory :) - not the root directory. If you have done it and the fixed it you should clear your cache in order to have it working :)

@Foddie2
Copy link

Foddie2 commented Sep 26, 2023

Still getting this error

@nobkd
Copy link
Contributor

nobkd commented Sep 26, 2023

Hello @Foddie2
Are you able provide a reproduction e.g. with Stackblitz or can you provide a log?
Thank you.

@CodyBontecou
Copy link

CodyBontecou commented Oct 31, 2023

I'm seeing this issue when I place the dynamic slug within a nested directory. I.e. pages/blog/[...slug].vue.

Here's a reproduction.

@nobkd
Copy link
Contributor

nobkd commented Oct 31, 2023

@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. 🤔

@CodyBontecou
Copy link

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

@rockfang
Copy link

rockfang commented Dec 20, 2023

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

@zaviermiller
Copy link

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

I am getting the same thing. Turning ssr: false makes it work, but then I'm losing a lot of the benefits of nuxt.

@coverspace
Copy link

Is this problem being resolved? I have the same problem here

@DenysMenfredy
Copy link

same here, it works in development mode, but not working in production mode. And I don't want to set ssr: false

@thanhthinh95
Copy link

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

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