Skip to content
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

feat(core): support for multiple layouts #50

Merged
merged 6 commits into from
Oct 1, 2022
Merged

Conversation

ojvribeiro
Copy link
Owner

@ojvribeiro ojvribeiro commented Sep 30, 2022

Resolves #30.

This PR adds support for multiple layouts by simply creating a Vue file inside the layouts folder.

Creating a layout

Let's say that you want to create a layout for the "about" page. Simply create an about.vue file inside the layouts folder:

image

You can use kebab-case or PascalCase in the layout name.

Inside layouts/about.vue, create your HTML layout around a <slot /> tag:

<!-- layouts/about.vue -->

<template>
  <!-- Put your layout around the slot -->
  <slot />
  <!-- Put your layout around the slot -->
</template>

Using the <Layout> component

In the pages/about.vue, wrap the content inside a <Layout> component, passing the layout name as a prop:

<!-- pages/about.vue -->

<template>
  <Layout name="about">
    That's my About page
  </Layout>
</template>

Your page will inherit all the layouts/about.vue components and styles.

ℹ️ Tip: If you use the <Layout> component in the root app.vue file, the layout will be applied to every page.

@ojvribeiro ojvribeiro added the enhancement New feature or request label Sep 30, 2022
@ojvribeiro ojvribeiro self-assigned this Sep 30, 2022
@vercel
Copy link

vercel bot commented Sep 30, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
vulmix ✅ Ready (Inspect) Visit Preview Sep 30, 2022 at 10:30PM (UTC)

@ojvribeiro ojvribeiro marked this pull request as ready for review September 30, 2022 22:30
@ojvribeiro ojvribeiro changed the title feat(core): built-in Layout component for multiple layouts feat(core): support for multiple layouts Oct 1, 2022
@ojvribeiro ojvribeiro merged commit 016bd09 into main Oct 1, 2022
@ojvribeiro ojvribeiro deleted the feate-page-layouts branch October 1, 2022 03:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create page layouts
1 participant