Skip to content

Commit

Permalink
Merge pull request #50 from ojvribeiro/feate-page-layouts
Browse files Browse the repository at this point in the history
feat(core): support for multiple layouts
  • Loading branch information
ojvribeiro committed Oct 1, 2022
2 parents 7a3d7a9 + 06ead4c commit 016bd09
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 5 deletions.
14 changes: 14 additions & 0 deletions .vulmix/components/Layout.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<template>
<component :is="`layout-${name}`">
<slot />
</component>
</template>

<script setup>
defineProps({
name: {
type: String,
default: 'default',
},
})
</script>
21 changes: 21 additions & 0 deletions .vulmix/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,27 @@ const router = createRouter({
routes: routes,
})


/**
* Layouts
*/
const layoutFiles = require.context('@layouts/', true, /\.(vue|js)$/i)

layoutFiles
.keys()
.map(key => {
const layoutName =
'layout-' +
key
.split('.')[1]
.replace(/\//g, '')
.replace(/([A-Z])/g, '-$1')
.replace(/(^-)/g, '')
.toLowerCase()

app.component(layoutName, layoutFiles(key).default)
})

app.use(router)
app.use(head)

Expand Down
1 change: 1 addition & 0 deletions .vulmix/mix.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class VulmixInit {
'@assets': path.resolve(__dirname, '../assets'),
'@components': path.resolve(__dirname, '../components'),
'@composables': path.resolve(__dirname, '../composables'),
'@layouts': path.resolve(__dirname, '../layouts'),
'@pages': path.resolve(__dirname, '../pages'),
'@sass': path.resolve(__dirname, '../assets/sass'),
},
Expand Down
5 changes: 5 additions & 0 deletions layouts/default.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<template>
<!-- Put your layout around the slot tag -->
<slot />
<!-- Put your layout around the slot tag -->
</template>
12 changes: 7 additions & 5 deletions tailwind.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
'./index.html',
'./.vulmix/**/pages/*.{vue,html,js}',
'./.vulmix/**/components/*.{vue,html,js}',
'./pages/*.{vue,html,js}',
'./components/*.{vue,html,js}',
'./app.vue',
'./.vulmix/**/pages/*.{vue,js}',
'./.vulmix/**/components/*.{vue,js}',
'./.vulmix/**/layouts/*.{vue,js}',
'./pages/*.{vue,js}',
'./components/*.{vue,js}',
'./layouts/*.{vue,js}',
],
theme: {
extend: {},
Expand Down

1 comment on commit 016bd09

@vercel
Copy link

@vercel vercel bot commented on 016bd09 Oct 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

vulmix – ./

vulmix.vercel.app
vulmix-ojvribeiro.vercel.app
vulmix-git-main-ojvribeiro.vercel.app

Please sign in to comment.