nuxt / content

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

Error on Nuxt Content for Static Site Generation : Document not found, overwrite this content with #not-found slot in <ContentDoc>. #2726

Closed dawadam closed 2 weeks ago

dawadam commented 3 months ago

Environment

Reproduction

Just install fresh nuxt and module @nuxt/content. Add a markdown file in "content" folder. Add a page in "pages" folder with <ContentDoc /> Add to nuxt config : ssr:false

1) Run in dev : npm run dev Appreciate markdown render

2) Generate npm run generate Check live npm run preview See error : Document not found, overwrite this content with #not-found slot in <ContentDoc>.

Describe the bug

When using Nuxt Content with markdown files. It works fine in development and when I generate production builds. The problem occurs when I try to disable SSR (Server-Side Rendering). An error appears when loading a markdown file:

Document not found, overwrite this content with #not-found slot in <ContentDoc>.

Additional context

No response

Logs

No response

shinGangan commented 3 months ago

Hello @dawadam , I'm also interested in this bug.

Is it possible to prepare this bug reproduction environment in StackBlitz?

llds66 commented 2 months ago

@dawadam Have you solved the problem? I can render for the first time, but when I refresh the page it says Document not found

Tobberoth commented 2 months ago

I had the same issue, using this undocumented experimental flag fixed it: https://github.com/nuxt/content/issues/1746#issuecomment-1346737779

Adeiko commented 2 months ago

I had the same issue, using this undocumented experimental flag fixed it: #1746 (comment)

It's surprising that this solution is so hidden. After spending hours trying to troubleshoot, simply adding this parameter to the Nuxt config resolved everything:

content: {
    experimental: {
      clientDB: true
    }
  }

This option isn’t even mentioned in the main documentation:

https://content.nuxt.com/get-started/configuration#experimental

Is there a specific reason why this isn’t documented?

dawadam commented 1 month ago

I had the same issue, using this undocumented experimental flag fixed it: #1746 (comment)

It's surprising that this solution is so hidden. After spending hours trying to troubleshoot, simply adding this parameter to the Nuxt config resolved everything:

content: {
    experimental: {
      clientDB: true
    }
  }

This option isn’t even mentioned in the main documentation:

https://content.nuxt.com/get-started/configuration#experimental

Is there a specific reason why this isn’t documented?

Thanks for that. It rings a bell, if it works I’ll need to try it again. I hadn't found the solution yet @shinGangan and @llds66.

iguilhermeluis commented 1 month ago

Thanks for that. This worked for me: https://github.com/nuxt/content/issues/2726#issuecomment-2315356141

shinGangan commented 2 weeks ago

Hi @dawadam , Has this issue already been resolved? If so, it may be ok to close it, are you sure?

dawadam commented 2 weeks ago

Hi @dawadam , Has this issue already been resolved? If so, it may be ok to close it, are you sure?

I will give it a try to verify.

dawadam commented 2 weeks ago

Installation (Nuxt + Content) :

npx nuxi@latest init content-app -t content

Change the configuration in nuxt.config.ts to disable server-side rendering:

export default defineNuxtConfig({
  ssr: false,
  // ...
});

Starting development:

npm run dev

Go to the article slug page:

http://localhost:3000/about

Working as expected: "About Content v2"

Generating for production:

npm run generate

Starting preview:

npm run preview

Go to the article slug page:

http://localhost:3000/about

See error:

Document not found, overwrite this content with #not-found slot in <ContentDoc>.

Apply @Adeiko's suggestion in nuxt.config.ts:

export default defineNuxtConfig({
  ssr: false,
  content: {
    experimental: {
      clientDB: true
    }
  },
  // ...
});

Generating for production:

npm run generate

Starting preview:

npm run preview

Go to the article slug page:

http://localhost:3000/about

Now it works: "About Content v2"

It should be added to the documentation! :)

PS : @shinGangan i'm not usung StackBlitz