Skip to content

Commit 27cceb4

Browse files
committed
feat: add nuxtify config
1 parent 39ad318 commit 27cceb4

File tree

7 files changed

+95
-8
lines changed

7 files changed

+95
-8
lines changed

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"cSpell.words": [
3+
"defu",
34
"nuxtify",
45
"nuxtifydev"
56
]

package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"dependencies": {
3232
"@mdi/js": "^7.4.47",
3333
"@nuxt/kit": "^3.16.1",
34+
"defu": "^6.1.4",
3435
"vuetify-nuxt-module": "^0.18.4"
3536
},
3637
"devDependencies": {

playground/app.vue

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1+
<script setup lang="ts">
2+
const nuxtifyConfig = useAppConfig().nuxtify
3+
</script>
4+
15
<template>
26
<div>
37
nuxtify-pages module playground!
48
<v-btn>
59
Test
610
</v-btn>
711
</div>
8-
</template>
912

10-
<script setup lang="ts">
11-
</script>
13+
<h2>nuxtifyConfig</h2>
14+
<pre>
15+
{{ nuxtifyConfig }}
16+
</pre>
17+
</template>

playground/nuxt.config.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,9 @@ export default defineNuxtConfig({
22
modules: ['../src/module'],
33
devtools: { enabled: true },
44
compatibilityDate: '2025-03-22',
5-
myModule: {},
5+
nuxtify: {
6+
brand: {
7+
name: 'nuxtify-pages-playground',
8+
},
9+
},
610
})

src/module.ts

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,33 @@ import {
44
createResolver,
55
installModule,
66
} from '@nuxt/kit'
7+
import { defu } from 'defu'
78

8-
// Module options TypeScript interface definition
9-
export interface ModuleOptions {}
9+
// Types
10+
import type { ModuleOptions } from '../src/runtime/types'
1011

1112
export default defineNuxtModule<ModuleOptions>({
1213
meta: {
1314
name: 'nuxtify-pages',
1415
configKey: 'nuxtify',
1516
compatibility: {
1617
nuxt: '>=3.16.0',
18+
bridge: false,
19+
},
20+
},
21+
defaults: {
22+
brand: {
23+
name: 'nuxtify-pages',
24+
domain: '',
25+
tagline: '',
26+
logo: {
27+
lightUrl: '',
28+
darkUrl: '',
29+
width: 200,
30+
mobileWidth: 150,
31+
},
1732
},
1833
},
19-
// Default configuration options of the Nuxt module
20-
defaults: {},
2134
async setup(_options, _nuxt) {
2235
const resolver = createResolver(import.meta.url)
2336

@@ -26,6 +39,11 @@ export default defineNuxtModule<ModuleOptions>({
2639
vuetifyOptions: resolver.resolve('./runtime/vuetify.config.ts'),
2740
})
2841

42+
// Expose module options to app config
43+
_nuxt.options.appConfig.nuxtify = defu(_nuxt.options.appConfig.nuxtify, {
44+
..._options,
45+
})
46+
2947
// Do not add the extension since the `.ts` will be transpiled to `.mjs` after `npm run prepack`
3048
addPlugin(resolver.resolve('./runtime/plugin'))
3149
},

src/runtime/types.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
interface BrandOptions {
2+
/**
3+
* The name of the brand.
4+
*
5+
* @default "nuxtify-pages"
6+
*/
7+
name?: string
8+
/**
9+
* The domain of the brand.
10+
*
11+
* @default ""
12+
*/
13+
domain?: string
14+
/**
15+
* The tagline of the brand.
16+
*
17+
* @default ""
18+
*/
19+
tagline?: string
20+
/**
21+
* The logo of the brand.
22+
*/
23+
logo?: {
24+
/**
25+
* The URL of the light logo. Recommended 5:1 aspect ratio (e.g. 400 x 80 px).
26+
*
27+
* @default ""
28+
*/
29+
lightUrl?: string
30+
/**
31+
* The URL of the dark logo. Recommended 5:1 aspect ratio (e.g. 400 x 80 px).
32+
*
33+
* @default ""
34+
*/
35+
darkUrl?: string
36+
/**
37+
* The width of the logo.
38+
*
39+
* @default 200
40+
*/
41+
width?: number
42+
/**
43+
* The width of the logo on mobile.
44+
*
45+
* @default 150
46+
*/
47+
mobileWidth?: number
48+
}
49+
}
50+
51+
export interface ModuleOptions {
52+
/**
53+
* Brand options
54+
*/
55+
brand?: BrandOptions
56+
}

0 commit comments

Comments
 (0)