-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
default layout not processed when using sub folder without a layout #130
Comments
I see it. You can work around by putting a file sub.vue in the /src with an empty template. Have to figure out best way to fix it. Feel free to submit PR if you have an idea |
i have other routes under the sub folder and the issue persist with all of them i've run in this issue with the version 0.9.0 |
@cirolosapio hello, If your application is not particularly complex, you can try using ClientSideLayout, which internally handles this issue this is example 👉 stackblitz |
@JohnCampionJr export function setupLayouts(routes) {
function deepSetupLayout(routes, parentLayout = undefined) {
return routes.map((route) => {
// Setup children's layout.
route.children = deepSetupLayout(route.children ?? [], route.component)
if (!route.component && route.children.length > 0) {
// If the route does not have a layout component and contains children, do not setup layout for the route.
return route
}
else {
// If a layout is specified, use the specified layout.
// Otherwise, check if the parent layout exists.
// If the parent layout does not exist, setup default layout.
return {
path: route.path,
component: layouts[route.meta?.layout] || (parentLayout ? undefined : layouts.default),
children: [{ ...route, path: '' }],
meta: {
isLayout: true,
},
}
}
})
}
return deepSetupLayout(routes)
} |
@cirolosapio I have run into this exact issue as well, any routes that are under a folder don't have default layouts in them. The bandaid fix I did was to add this block of code to every vue file I have. <route lang="yaml">
meta:
layout: default
</route> This now fixes the issue but obviously, this isn't ideal and it would be tedious. |
@markthree I saw the new ClientSideLayout but before using it I want to understand what the "limitations" are
@glennmichael123 yes i'm using this workaround atm |
@cirolosapio It only supports three options, |
although a default layout is set when using a sub folder if a layout is not specified in the route tag the default layout is not processed
stackblitz
The text was updated successfully, but these errors were encountered: