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 623 forks source link

Static sites generate 404 on conditional components #1642

Open retroriff opened 2 years ago

retroriff commented 2 years ago

Environment

Reproduction

https://stackblitz.com/github/retroriff/nuxt-refresh

Describe the bug

When a component is displayed conditionally, it returns a 404 with "nuxt generate", but it works on yarn dev. The v-if generates the error:

<PrivacyPolicy v-if="showComponent" />

Additional context

No response

Logs

No response

florianjs commented 2 years ago

It works for me.

npx nuxi generate

Once generated, with VS Code and the Live Server plugin installed :

cd dist/
code .

Into VS Code : “Go live” in the bottom-right corner.

retroriff commented 2 years ago

@Icesofty That's weird. When you toggle, do you see "Hello, world" or "Not found"?

florianjs commented 2 years ago

@Icesofty That's weird. When you toggle, do you see "Hello, world" or "Not found"?

Ho, I got it. I have a “Not found” message indeed. I tough it was an error page. I don't why, will check tomorrow.

I guess that you could use a v-show instead of a v-if inside your index.vue as a temporary solution.

retroriff commented 2 years ago

Hiding them with v-show is not a solution to us because we don't want those components to be rendered. As I said, it works perfectly on nuxt dev, and used to work on Nuxt 2.

ManasMadrecha commented 2 years ago

It is working properly.

image

retroriff commented 2 years ago

@ManasMadrecha Are you building it with "dev" or "generate"?

ManasMadrecha commented 2 years ago

Hey, it's working only on dev; on generate, it's showing Not Found.

image

This issue is relevant even on latest edge versions of both Nuxt (rc-14) and Content module as on today.