-
Notifications
You must be signed in to change notification settings - Fork 9
Is there any possibility to implement layouts? #1
Comments
Hey @d0whc3r, thanks for your interest! Yes, I think adding layouts as a feature is a good idea 😄 |
Layouts are in a sense already a feature, as you can create a layout for a subset of pages by using the nested routes feature like so:
As I see it the problem that is to be solved is that we can't currently "reset" layouts. i.e. if I have a structure like this:
Then my pages under the To solve this, we have to hoist route definitions up to the top level so that they are only children of their given layout. To signal that a specific directory and its sub-directories should undergo hoisting, we can mark it with a layout file as suggested:
This would then result in something like the following routes: [
{
path: '/users',
component: '/pages/users.vue',
children: [
{
name: 'users',
path: '',
component: '/pages/users/index.vue'
}
]
},
{
path: '/users/settings',
component: '/pages/users/settings/_layout.vue',
children: [
{
name: 'users-settings',
path: '',
component: '/pages/users/settings/index.vue'
}
]
}
] |
I think I prefer to have the layout file named something like
|
Would be nice if we can set a layout in the base pages directory 👍 |
Hello ! You can easily create <template inherit-attrs="false">
<Navbar />
<slot></slot>
<Footer />
</template>
And use them in your pages: <template>
<DefaultLayout>
<h1>Awesome Website</h1>
</DefaultLayout>
</template> |
Now I'm using https://github.com/ktsn/vue-router-layout which works great, but no vue3 support. |
Something like svelte routify, for example: https://www.youtube.com/watch?v=gYMNfcXPwrQ
With
_layout
and_reset
or other approach like multiple_layouts
one for each folderThe text was updated successfully, but these errors were encountered: