I'd like to have the following URL structure:
URL | Role |
---|---|
/ | markdown contents of /index.md |
/about | markdown contents of /about.md |
/cookies | markdown contents of /cookies.md |
/privacy-policy | markdown contents of /privacy-policy.md |
/category1 | category1 index page |
/category1/post1 | markdown contents of /category1/post1.md |
/category1/post2 | markdown contents of /category1/post2.md |
/category2 | category2 index page |
/category2/post1 | markdown contents of /category2/post1.md |
/category2/post2 | markdown contents of /category2/post2.md |
I'd like to avoid having to create separate .js
files for my content in the root directory (so no /about.js
, /cookies.js
, etc), but if I try something like this...
pages/
index.js
[root_article_id].js
[category]/
index.js
[category_article_id].js
... then Next.js complains because it cannot decide when I request the URL /about
whether if it should use [category]/index.js
or [root_article_id].js
, even though I feel the latter should be called first, and if it doesn't want to deal with the request (i.e. if there's no about.md
in the root of my markdown directory), then it should fall back to [category]/index.js
, which still could pass the request through to the 404 handler if [category].js
spits it out.
What's the correct way of structuring Next.js files for this? Do I really need to have separate .js
files for my markdown files in the root content directory?