Hi and thanks for what you are doing!
In this topic, I found instructions on how to allow content writers to create pages. To do this, create the [[...path]].js file in the pages folder. But I did not find the answer to the question, can these pages created by the writers have nested pages? If yes, what should be the document structure for this?
In Next.js, to create nested pages, it is enough to create a folder with the name of the page, place the index.js file in it and a file with the name in square brackets, which will be part of the nested page address. But a similar structure with the [[...path]] folder does not work for me.
Hi @irbris ,
Thank you for reaching out to us.
You are absolutely right about choosing the way for routing your site.
[...path.js] is the way of using slugs in next js, and it works for the large number of pages in the tree i.e. if your site has page URLs like
/testpages/a/b/c/d, then you can handle both of this cases by creating a folder structure like
For more information API Routes: Dynamic API Routes | Next.js.
Give this a try and let me know if you have any further questions.
Thank you very much for your response!
Let me clarify my question a bit.
I have Home and Blog pages on my site. The Blog page has posts at blog/post1, blog/post2, and so on.
The project structure is as follows: in the pages folder there is an index.js file and a blog folder in which the index.js file and the [post].js file are located
What should be the structure of the project so that content writers can create other pages, and create new blog posts?
Your question is probably more on the Prismic side than the front-end side.
In your case, you can create a custom type in Prismic as
blog-post and create a document using this custom type. Content writers can create multiple documents using this custom type.
On the front end, you can create a folder structure like this:
and your [post].js should be able to handle all of the blog-posts which are created by content writers in Prismic.
Let me know if you have any further questions.