nuxtpage: child page inside parent page
Hi, I have this page structure
app.vue
layouts/
--default.vue
pages/
--categories
----[category].vue
----index.vue
my problem is that i can't render the [category].vue inside the <nuxtPage /> from index.vue from the same folder... it just replaces the whole page, instead rendering the subcategories inside the nuxtPage...
What I'm doing wrong?
8 Replies
What you're trying to achieve is a "wrapper layout" around the
[category].vue
page, am I right?yes correct.
so I have the main layout with the sidebar and then the categories sidebar
url should be domain.com/categories and if I select a category domain.com/categories/cat1
I also tried to create a second layout
I'm pretty sure for this you need to create a categories.vue file in pages rather than running it off an index file in the sub folder then it should work for you
What @Josh Donnell says + you don't need
<Nuxt Page />
within a page or a layout.
Without using a new layout, what worked for me was:
pages/categories.vue:
pages/categories/index.vue:
pages/categories/[category].vue:
and no app.vue file
@Gregor
Here is a very simple example for you.
https://stackblitz.com/edit/github-zmwvyh?file=pages%2Fcategories%2F%5Bid%5D.vue
Josh Donnell
StackBlitz
Nuxt - Starter - StackBlitz
Create a new Nuxt project, module, layer or start from a theme with our collection of starters.
thank you all, works brilliant now 🙂
placing the categories/index.vue outside the folder and rename it to categories.vue solved my problem