Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Open
shawnwildermuth opened this issue Jan 30, 2024 · 3 comments
Open

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

shawnwildermuth opened this issue Jan 30, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@shawnwildermuth
Copy link

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

@markthree markthree self-assigned this Jan 31, 2024
@markthree
Copy link
Collaborator

@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
Copy link
Collaborator

markthree commented Jan 31, 2024

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
Copy link
Collaborator

markthree commented Jan 31, 2024

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

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants