Nextjs app /(dashboard)/task/[module]/[chapter]
Answered
Polish posted this in #help-forum
PolishOP
As a beginner, I try to cope with Nextjs, my goal is to create a list that dynamically expands itself.
It should look something like this later:
- modulename1
- chaptername1
- chaptername2
- modulename2
- chaptername1
How do you build something like that professionally, do you use an object with titles,.... Or do you use fs modules or use metadata from any page.tsx
I hope someone explains to me how to build it, I’m a little disoriented Tyyy
It should look something like this later:
- modulename1
- chaptername1
- chaptername2
- modulename2
- chaptername1
How do you build something like that professionally, do you use an object with titles,.... Or do you use fs modules or use metadata from any page.tsx
I hope someone explains to me how to build it, I’m a little disoriented Tyyy
Answered by B33fb0n3
you can use a catch all segment like this: /task/[...chapters]. Like that you can access all elements from an array:
Like that you can work with them further. Either using a dynamic import of mdx files or loading pages from database or whatever you current setup is
Route Example URL params
app/task/[...chapters]/page.js /task/a { chapters: ['a'] }
app/task/[...chapters]/page.js /task/a/b { chapters: ['a', 'b'] }
app/task/[...chapters]/page.js /task/a/b/c { chapters: ['a', 'b', 'c'] }Like that you can work with them further. Either using a dynamic import of mdx files or loading pages from database or whatever you current setup is
4 Replies
@Polish As a beginner, I try to cope with Nextjs, my goal is to create a list that dynamically expands itself.
It should look something like this later:
- modulename1
- chaptername1
- chaptername2
- modulename2
- chaptername1
How do you build something like that professionally, do you use an object with titles,.... Or do you use fs modules or use metadata from any page.tsx
I hope someone explains to me how to build it, I’m a little disoriented Tyyy
you can use a catch all segment like this: /task/[...chapters]. Like that you can access all elements from an array:
Like that you can work with them further. Either using a dynamic import of mdx files or loading pages from database or whatever you current setup is
Route Example URL params
app/task/[...chapters]/page.js /task/a { chapters: ['a'] }
app/task/[...chapters]/page.js /task/a/b { chapters: ['a', 'b'] }
app/task/[...chapters]/page.js /task/a/b/c { chapters: ['a', 'b', 'c'] }Like that you can work with them further. Either using a dynamic import of mdx files or loading pages from database or whatever you current setup is
Answer
PolishOP
Ok catch all and the … dots are new ty I need to search the docs and try to understand ❤️ Its helpfull If I get a direction tyyy for ur awesome advice
happy to help