How do I load markdown in the repository with cf pages?
Answered
okakajp (Japanese) posted this in #help-forum
I'm trying to create a site that uses markdown in Nextjs, and the
How can I use the files in the repository without using the fs module?
(I stopped using next/mdx because there were many errors)
(This sentence uses a translation from Japanese to English)
npm run dev dollar works well, but I'm told that there is no module in the cf pages after committing.How can I use the files in the repository without using the fs module?
(I stopped using next/mdx because there were many errors)
(This sentence uses a translation from Japanese to English)
Answered by joulev
remove
export const runtime = edge;, add generateStaticParams https://nextjs.org/docs/app/api-reference/functions/generate-static-params to make it build the whole thing at build time. then the page is static and the edge runtime is not required.27 Replies
I think you can render it as static page
When you try to build a [slug] page in Cloudflare pages, you will see that edge is required.
Can i see your file structure?
So I think next/mdx is the only option.
Otherwise deploy to other platforms like Amplify, Google cloud run
Otherwise deploy to other platforms like Amplify, Google cloud run
It may be a little difficult to understand because it is a Japanese site
@"use php" ..
When using next/mdx, the following error occurs and you don't know where to put
"use client"@"use php" At the top of the file
Is this image page.mdx?
Try to add there
Page.mdx
@"use php" Page.mdx
ok I'll try it now
@okakajp (Japanese) https://github.com/SKYNETWORK-MCBE/sky-wikisite-beta/tree/markdown-test
remove
export const runtime = edge;, add generateStaticParams https://nextjs.org/docs/app/api-reference/functions/generate-static-params to make it build the whole thing at build time. then the page is static and the edge runtime is not required.Answer
@okakajp (Japanese) remove `fs` ?
No. Remove the runtime export. And add generateStaticParams to tell nextjs which
slug you will have so nextjs will build it at build time for you@okakajp (Japanese) An error has occurred
How does your page look like at the moment
@okakajp (Japanese) Click to see attachment
Well yeah because you need to replace that placeholder generateStaticParams with your own
Use fs to list out all the possible values of slug and use it as the return value of generateStaticParams
Check the link I sent above for the documentation
I did it, thank you very much
I still do believe next/mdx will be a better option. But this also works