vite-plugin-vue-layouts icon indicating copy to clipboard operation
vite-plugin-vue-layouts copied to clipboard

Nested Pages (unplugin-vue-router) nest the layout pages

Open shawnwildermuth opened this issue 1 year ago • 6 comments
trafficstars

Is this by design?

My layout is:

image

But when I look at the generated code, the default layout is outside of the yellow layout (I know they're nested routes but this doesn't seem right). The layouts look like:

<!-- layouts/default.vue -->
<template>
  <div class="bg-gray-200 p-2">
    <h1>Default Layout</h1>
    <RouterView></RouterView>
  </div>
</template>
<!-- layouts/yellow.vue -->
<template>
  <div class="border border-yellow-300 bg-neutral">
    <h1>Yellow Layout</h1>
    <RouterView></RouterView>
  </div>
</template>

The result is this:

image

But that doesn't seem right.

Repro:

demo.zip

shawnwildermuth avatar Jan 30 '24 07:01 shawnwildermuth

@shawnwildermuth Yes, it's a design problem.

An easy way to solve this problem is to create pages/customer.vue and set the layout to false

<template>
    <RouterView />
</template>

<route lang="json">
{
    "meta": {
        "layout": false
    }
}
</route>

image

markthree avatar Jan 31 '24 05:01 markthree

I've tried to solve the problem, but it seems to ignore parameter routing (There may be other scenarios that have not been tested), and I thought I'd try to see if I could come up with a more elegant solution in the near future (when I'm done with my latest work 😭)

Related issue → #134 Related pr → #137

Overall, this is a problem with the design of the file routing structure of unplugin-vue-router, and we can only try to make it make sense (in terms of layout)

markthree avatar Jan 31 '24 05:01 markthree

@JohnCampionJr I think there should be an option to configure whether or not nested routes inherit the default layout

markthree avatar Jan 31 '24 06:01 markthree

After a year, has there been any progress in this issue? Is there a better solution?

He110te4m avatar Mar 17 '25 09:03 He110te4m

any news?

reslear avatar May 26 '25 16:05 reslear

@reslear I suggest you to subscribe to this issue since vite-plugin-vue-layouts-next is not dead and is being used by the likes of vuetify: https://github.com/loicduong/vite-plugin-vue-layouts-next/issues/6

darkbasic avatar May 27 '25 09:05 darkbasic