-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
Nuxt 3 does not respect layouts in separate folders #14275
Comments
Check out nuxt/framework#5842 for prior work. Closed only due to repository migration + lack of time to add my suggestion below. Here are my thoughts in case anyone else wants to pick this: I think we do need to support layouts in nested folders, and this was a nice implementation 👌 However, on reflection I think the most consistent/intuitive approach is to follow the pattern of the components directory - producing & deduplicating segments. We can extract the utility and share it between the two parts of Nuxt. For example:
|
This comment was marked as duplicate.
This comment was marked as duplicate.
@danielroe I created a pull request for a fix on this issue. Please check it out in the following link. —> #20190 |
@danielroe Any update? I need this enhancement to create the following structure;
it works on nuxt2:
But it didn't work on nuxt3 In addition, it would be very useful if you could add this defining support for defining default and error layout |
Feel free to open a new PR taking my comments into account if you have time. |
Environment
Nuxt Version
Reproduction
Steps to reproduce
On a clean Nuxt 3 install.
Create a layout inside a folder like.
layouts/mobile/custom.vue
Use it in a page as follows.
<NuxtLayout name="mobile/custom"> some code ... </NuxtLayout>
Describe the bug
When I create a layout inside a folder like "layouts/mobile/custom.vue" and use it inside of "pages/index.vue" on a clean install of Nuxt 3 as follows.
<NuxtLayout name="mobile/custom"> some code ... </NuxtLayout>
It does not work, I don't know if this feature is not supported yet or if it is a bug, because when I went through the Nuxt 2 info I found this which came out thanks to an issue of this exact same problem in Nuxt 2
Adds support for folders in /layouts nuxt/nuxt.js#12765
Normal layout use like Nuxt 3 documentation works just fine, "layouts/custom.vue" inside of "pages/index.vue" like this.
<NuxtLayout name="custom"> some code ... </NuxtLayout>
What is Expected?
Is expected to work exactly as normal layouts would.
What is actually happening?
Got an error in console as if the layout does not exists.
Invalid layout "mobile/custom" selected.
The text was updated successfully, but these errors were encountered: