Replies: 1 comment
-
Related: I have the same issue as well, but I think nuxt/content is not ready yet for a generated portfolio just yet (I have one as well but am having issues with generating it the same way). |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm currently building a personal blog for myself and hosting it on Netlify as a static website. I figured Nuxt Content is a good solution for blog posts and project listings. My blog is open-source and kept here. In this project listing page, I'm rendering all the projects as a list from a YAML file with small excerpt of the project (although each entry has other details such as languages, frameworks, etc. too). When a user clicks on an entry, it takes the slug field and swap out the list with the detail page where a ContentDoc loads the markdown file from content/data/projects/[slug].md. If that fails i.e. because the file is not there, then it uses the "other details" mentioned above such as frameworks, etc., and generates a default project details page.
This works fine in my local because it runs in SSR mode (probably shouldn't be doing that since the production target is static). But when I push it to production it throws me this error:

I understand this has to do with static sites prerendering routes and this particular API route might not exist. Since all possible project details markdown files lie inside the
content/data/projects
folder, I would like to do a directory fetch, and add each route to the prerenderer so that in production, the API calls don't fail. How do I go about achieving this? Kindly help. Thanks.Update: I wrote a hacky workaround, and this makes Nuxt's crawler push all my dynamic project listing into it's pre-renderer. But I it's not very elegant because besides exposing an additional route unnecessarily, it pollutes my builds with a lot of 404s for the files that don't currently exist everytime I run
pnpm generate
. I see there is aprerender
hook but how can I can tell Nuxt's crawler to include files in mycontent/data/projects
to the prerender? but using Nuxt Content's hashified prerendered URLs for those routes? (which seems to be what it's doing).Beta Was this translation helpful? Give feedback.
All reactions