hannoeru / vite-plugin-pages

File system based route generator for ⚡️Vite
MIT License
1.84k stars 127 forks source link

Disable layout for routes #339

Closed folamy closed 1 year ago

folamy commented 1 year ago

Description

I would like to disable layout for some certain routes, like the landing page. Is that possible?

Suggested solution

<route lang="yaml">
name: Home
meta:
  layout: false
</route>

Alternative

No response

Additional context

No response

Validations

abdul-alhasany commented 1 year ago

Are you using this plugin: vite-plugin-vue-layouts?

Otherwise vite-plugin-pages does does not have a layout option. You can, however, use the meta value to manipulate your component.

For example: In your component you add the code you had:

<route lang="yaml">
name: Home
meta:
  layout: false
</route>

And then when route loads the parent component (where is ) you can do something like this:

const shouldShowLayout = computed(() => {
    const { meta } = useRoute();
    return meta.layout !== false;
});

I might be able to help more if more code was provided.