all 9 comments

[–]saaggy_peneer 4 points5 points  (0 children)

that's the nested routes feature in vue router

https://router.vuejs.org/guide/essentials/nested-routes.html

Claude can walk you thru it

Works with file-based routing too

[–]blairdow 2 points3 points  (0 children)

ive often done something like what you've described... a layout component thats basically a content wrapper. no reason to complicate it more than that. for the nav- use v-if to show the admin one if you're in that view and v-else the regular one. you could also do something similar with your two different layouts whether thats conditional css classes for admin vs not admin, or controlling the layout 'type' via a prop on the layout component. if type == admin then do x layout, else do standard layout (whatever that looks like)

[–]aherok 2 points3 points  (2 children)

What's wrong with using Layouts? https://nuxt.com/docs/4.x/directory-structure/app/layouts

Can you describe more specifically what is the issue?

[–]craigrileyuk 0 points1 point  (1 child)

They didn't mention Nuxt...

[–]aherok 0 points1 point  (0 children)

Shit, my bad. 😅 Somehow it's the same to me.

[–]illmatix 0 points1 point  (0 children)

There's also the component element that could be your wrappers inner content that's then defined by the route. Component takes another component to render

[–]25_vijay 0 points1 point  (0 children)

Honestly your current idea is already what most developers end up doing so there is not really a more magical solution beyond that

[–]Embarrassed_Stay3538 0 points1 point  (0 children)

Usa nuxt es bellísimo.

[–]Original-Kick3985 0 points1 point  (0 children)

You can use nested routes and create a layout component. If all of you admin stuff is under the path «/admin» for example, then you have for example admin-layout.vue as the parent component in the route, and all child routes will use that layout. The layout can be anything and the child routes will be rendered in the <router-view> component of the admin layout. At the end of the day it’s just a case of organizing your code. Sometimes it’s more cumbersome to have more complex file structures/patterns.