@happydesigns/ui 0.17.3 → 0.17.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/layouts/content.vue +12 -2
- package/app/layouts/page.vue +12 -1
- package/nuxt.config.ts +64 -60
- package/package.json +1 -1
- package/schemas/traits.ts +95 -95
package/app/layouts/content.vue
CHANGED
|
@@ -17,7 +17,18 @@ const { data: page } = await usePageContent<C, Collections['page']>({
|
|
|
17
17
|
collection: () => collection,
|
|
18
18
|
})
|
|
19
19
|
|
|
20
|
-
const
|
|
20
|
+
const variant = computed(() => {
|
|
21
|
+
if (typeof route.meta.variant === 'string' && route.meta.variant) {
|
|
22
|
+
return route.meta.variant
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (typeof route.meta.layout === 'string' && route.meta.layout) {
|
|
26
|
+
return route.meta.layout
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return collection
|
|
30
|
+
})
|
|
31
|
+
const { has } = useVariant(variant)
|
|
21
32
|
const hasHeader = has('header')
|
|
22
33
|
const hasToc = has('toc')
|
|
23
34
|
|
|
@@ -32,7 +43,6 @@ if (!page.value) {
|
|
|
32
43
|
usePageSeo(page)
|
|
33
44
|
|
|
34
45
|
const renderToc = computed(() => hasToc.value
|
|
35
|
-
&& page.value?.toc !== false
|
|
36
46
|
&& Boolean(page.value?.body?.toc?.links?.length))
|
|
37
47
|
const header = computed(() => resolvePageHeader(page.value))
|
|
38
48
|
</script>
|
package/app/layouts/page.vue
CHANGED
|
@@ -16,7 +16,18 @@ const { data: page } = await usePageContent<C, Collections['page']>({
|
|
|
16
16
|
collection: () => collection,
|
|
17
17
|
})
|
|
18
18
|
|
|
19
|
-
const
|
|
19
|
+
const variant = computed(() => {
|
|
20
|
+
if (typeof route.meta.variant === 'string' && route.meta.variant) {
|
|
21
|
+
return route.meta.variant
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (typeof route.meta.layout === 'string' && route.meta.layout) {
|
|
25
|
+
return route.meta.layout
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return collection
|
|
29
|
+
})
|
|
30
|
+
const { has } = useVariant(variant)
|
|
20
31
|
const hasHeader = has('header')
|
|
21
32
|
|
|
22
33
|
if (!page.value) {
|
package/nuxt.config.ts
CHANGED
|
@@ -1,60 +1,64 @@
|
|
|
1
|
-
// https://nuxt.com/docs/api/configuration/nuxt-config
|
|
2
|
-
export default defineNuxtConfig({
|
|
3
|
-
|
|
4
|
-
$meta: {
|
|
5
|
-
name: '@happydesigns/ui',
|
|
6
|
-
},
|
|
7
|
-
|
|
8
|
-
components: [
|
|
9
|
-
{ path: './components', pathPrefix: false, prefix: 'H' },
|
|
10
|
-
],
|
|
11
|
-
|
|
12
|
-
devtools: { enabled: true },
|
|
13
|
-
|
|
14
|
-
modules: [
|
|
15
|
-
'@happydesigns/nuxt-variants',
|
|
16
|
-
'@nuxt/ui',
|
|
17
|
-
'@nuxt/content',
|
|
18
|
-
'nuxt-studio',
|
|
19
|
-
],
|
|
20
|
-
|
|
21
|
-
variants: {
|
|
22
|
-
registry: {
|
|
23
|
-
// Data features — schema only, no config
|
|
24
|
-
dates: {},
|
|
25
|
-
authors: {},
|
|
26
|
-
category: {},
|
|
27
|
-
published: {},
|
|
28
|
-
header: {},
|
|
29
|
-
toc: {},
|
|
30
|
-
links: {},
|
|
31
|
-
location: {},
|
|
32
|
-
layout: {},
|
|
33
|
-
separatorButtons: {},
|
|
34
|
-
|
|
35
|
-
// UI features — config defined in app.config.ts
|
|
36
|
-
user: {},
|
|
37
|
-
backButton: {},
|
|
38
|
-
copyButton: {},
|
|
39
|
-
separator: {},
|
|
40
|
-
surround: {},
|
|
41
|
-
|
|
42
|
-
// Collection variants — extends chains defined here for graph generation
|
|
43
|
-
snippet: {},
|
|
44
|
-
article: {
|
|
45
|
-
extends: ['dates', 'authors', 'category', 'published', 'header', 'toc', 'surround', 'copyButton', 'separator', 'backButton'],
|
|
46
|
-
config: {},
|
|
47
|
-
},
|
|
48
|
-
event: {
|
|
49
|
-
extends: ['dates', 'location', 'category', 'links', 'published', 'header', 'toc', 'surround', 'copyButton', 'separator', 'backButton'],
|
|
50
|
-
config: {},
|
|
51
|
-
},
|
|
52
|
-
page: {
|
|
53
|
-
extends: ['layout', 'header'
|
|
54
|
-
config: {},
|
|
55
|
-
},
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
1
|
+
// https://nuxt.com/docs/api/configuration/nuxt-config
|
|
2
|
+
export default defineNuxtConfig({
|
|
3
|
+
|
|
4
|
+
$meta: {
|
|
5
|
+
name: '@happydesigns/ui',
|
|
6
|
+
},
|
|
7
|
+
|
|
8
|
+
components: [
|
|
9
|
+
{ path: './components', pathPrefix: false, prefix: 'H' },
|
|
10
|
+
],
|
|
11
|
+
|
|
12
|
+
devtools: { enabled: true },
|
|
13
|
+
|
|
14
|
+
modules: [
|
|
15
|
+
'@happydesigns/nuxt-variants',
|
|
16
|
+
'@nuxt/ui',
|
|
17
|
+
'@nuxt/content',
|
|
18
|
+
'nuxt-studio',
|
|
19
|
+
],
|
|
20
|
+
|
|
21
|
+
variants: {
|
|
22
|
+
registry: {
|
|
23
|
+
// Data features — schema only, no config
|
|
24
|
+
dates: {},
|
|
25
|
+
authors: {},
|
|
26
|
+
category: {},
|
|
27
|
+
published: {},
|
|
28
|
+
header: {},
|
|
29
|
+
toc: {},
|
|
30
|
+
links: {},
|
|
31
|
+
location: {},
|
|
32
|
+
layout: {},
|
|
33
|
+
separatorButtons: {},
|
|
34
|
+
|
|
35
|
+
// UI features — config defined in app.config.ts
|
|
36
|
+
user: {},
|
|
37
|
+
backButton: {},
|
|
38
|
+
copyButton: {},
|
|
39
|
+
separator: {},
|
|
40
|
+
surround: {},
|
|
41
|
+
|
|
42
|
+
// Collection variants — extends chains defined here for graph generation
|
|
43
|
+
snippet: {},
|
|
44
|
+
article: {
|
|
45
|
+
extends: ['dates', 'authors', 'category', 'published', 'header', 'toc', 'surround', 'copyButton', 'separator', 'backButton'],
|
|
46
|
+
config: {},
|
|
47
|
+
},
|
|
48
|
+
event: {
|
|
49
|
+
extends: ['dates', 'location', 'category', 'links', 'published', 'header', 'toc', 'surround', 'copyButton', 'separator', 'backButton'],
|
|
50
|
+
config: {},
|
|
51
|
+
},
|
|
52
|
+
page: {
|
|
53
|
+
extends: ['layout', 'header'],
|
|
54
|
+
config: {},
|
|
55
|
+
},
|
|
56
|
+
content: {
|
|
57
|
+
extends: ['page', 'toc'],
|
|
58
|
+
config: {},
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
studio: false,
|
|
64
|
+
})
|
package/package.json
CHANGED
package/schemas/traits.ts
CHANGED
|
@@ -1,95 +1,95 @@
|
|
|
1
|
-
import { property } from '@nuxt/content'
|
|
2
|
-
import { z } from 'zod'
|
|
3
|
-
|
|
4
|
-
export const datesTrait = {
|
|
5
|
-
schema: z.object({
|
|
6
|
-
date: z.date().optional(),
|
|
7
|
-
dateEnd: z.date().optional(),
|
|
8
|
-
}),
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const authorsTrait = {
|
|
12
|
-
schema: z.object({
|
|
13
|
-
authors: z.array(z.string()).optional(),
|
|
14
|
-
}),
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const categoryTrait = {
|
|
18
|
-
schema: z.object({
|
|
19
|
-
category: z.string().optional(),
|
|
20
|
-
}),
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export const publishedTrait = {
|
|
24
|
-
schema: z.object({
|
|
25
|
-
published: z.boolean().default(true),
|
|
26
|
-
}),
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export const headerTrait = {
|
|
30
|
-
schema: z.object({
|
|
31
|
-
header: property(z.object({})).inherit('@nuxt/ui/components/PageHeader.vue').optional(),
|
|
32
|
-
}),
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export const tocTrait = {
|
|
36
|
-
schema: z.object({
|
|
37
|
-
toc: z.boolean().default(true),
|
|
38
|
-
}),
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export const linksTrait = {
|
|
42
|
-
schema: z.object({
|
|
43
|
-
links: z.array(
|
|
44
|
-
property(z.object({})).inherit('@nuxt/ui/components/Button.vue'),
|
|
45
|
-
).optional(),
|
|
46
|
-
}),
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export const locationTrait = {
|
|
50
|
-
schema: z.object({
|
|
51
|
-
location: z.object({
|
|
52
|
-
name: z.string(),
|
|
53
|
-
url: z.string().optional(),
|
|
54
|
-
}).optional(),
|
|
55
|
-
}),
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export const layoutTrait = {
|
|
59
|
-
schema: z.object({
|
|
60
|
-
layout: z.enum(['default', 'page', 'content']).optional(),
|
|
61
|
-
}),
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export const userTrait = {
|
|
65
|
-
schema: z.object({
|
|
66
|
-
username: z.string(),
|
|
67
|
-
name: z.string().optional(),
|
|
68
|
-
description: z.string().optional(),
|
|
69
|
-
to: z.string().optional(),
|
|
70
|
-
avatar: z.object({
|
|
71
|
-
src: property(z.string()).editor({ input: 'media' }).optional(),
|
|
72
|
-
alt: z.string().optional(),
|
|
73
|
-
icon: property(z.string()).editor({ input: 'icon' }).optional(),
|
|
74
|
-
text: z.string().optional(),
|
|
75
|
-
}).optional(),
|
|
76
|
-
socials: z.array(z.object({
|
|
77
|
-
name: z.string(),
|
|
78
|
-
url: z.url(),
|
|
79
|
-
})).optional(),
|
|
80
|
-
email: z.email().optional(),
|
|
81
|
-
}),
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export const variantSchemas = {
|
|
85
|
-
dates: datesTrait.schema,
|
|
86
|
-
authors: authorsTrait.schema,
|
|
87
|
-
category: categoryTrait.schema,
|
|
88
|
-
published: publishedTrait.schema,
|
|
89
|
-
header: headerTrait.schema,
|
|
90
|
-
toc: tocTrait.schema,
|
|
91
|
-
links: linksTrait.schema,
|
|
92
|
-
location: locationTrait.schema,
|
|
93
|
-
layout: layoutTrait.schema,
|
|
94
|
-
user: userTrait.schema,
|
|
95
|
-
}
|
|
1
|
+
import { property } from '@nuxt/content'
|
|
2
|
+
import { z } from 'zod'
|
|
3
|
+
|
|
4
|
+
export const datesTrait = {
|
|
5
|
+
schema: z.object({
|
|
6
|
+
date: z.date().optional(),
|
|
7
|
+
dateEnd: z.date().optional(),
|
|
8
|
+
}),
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const authorsTrait = {
|
|
12
|
+
schema: z.object({
|
|
13
|
+
authors: z.array(z.string()).optional(),
|
|
14
|
+
}),
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const categoryTrait = {
|
|
18
|
+
schema: z.object({
|
|
19
|
+
category: z.string().optional(),
|
|
20
|
+
}),
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const publishedTrait = {
|
|
24
|
+
schema: z.object({
|
|
25
|
+
published: z.boolean().default(true),
|
|
26
|
+
}),
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const headerTrait = {
|
|
30
|
+
schema: z.object({
|
|
31
|
+
header: property(z.object({})).inherit('@nuxt/ui/components/PageHeader.vue').optional(),
|
|
32
|
+
}),
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const tocTrait = {
|
|
36
|
+
schema: z.object({
|
|
37
|
+
toc: z.boolean().default(true),
|
|
38
|
+
}),
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export const linksTrait = {
|
|
42
|
+
schema: z.object({
|
|
43
|
+
links: z.array(
|
|
44
|
+
property(z.object({})).inherit('@nuxt/ui/components/Button.vue'),
|
|
45
|
+
).optional(),
|
|
46
|
+
}),
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export const locationTrait = {
|
|
50
|
+
schema: z.object({
|
|
51
|
+
location: z.object({
|
|
52
|
+
name: z.string(),
|
|
53
|
+
url: z.string().optional(),
|
|
54
|
+
}).optional(),
|
|
55
|
+
}),
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export const layoutTrait = {
|
|
59
|
+
schema: z.object({
|
|
60
|
+
layout: z.enum(['default', 'page', 'content']).optional(),
|
|
61
|
+
}),
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export const userTrait = {
|
|
65
|
+
schema: z.object({
|
|
66
|
+
username: z.string(),
|
|
67
|
+
name: z.string().optional(),
|
|
68
|
+
description: z.string().optional(),
|
|
69
|
+
to: z.string().optional(),
|
|
70
|
+
avatar: z.object({
|
|
71
|
+
src: property(z.string()).editor({ input: 'media' }).optional(),
|
|
72
|
+
alt: z.string().optional(),
|
|
73
|
+
icon: property(z.string()).editor({ input: 'icon' }).optional(),
|
|
74
|
+
text: z.string().optional(),
|
|
75
|
+
}).optional(),
|
|
76
|
+
socials: z.array(z.object({
|
|
77
|
+
name: z.string(),
|
|
78
|
+
url: z.url(),
|
|
79
|
+
})).optional(),
|
|
80
|
+
email: z.email().optional(),
|
|
81
|
+
}),
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export const variantSchemas = {
|
|
85
|
+
dates: datesTrait.schema,
|
|
86
|
+
authors: authorsTrait.schema,
|
|
87
|
+
category: categoryTrait.schema,
|
|
88
|
+
published: publishedTrait.schema,
|
|
89
|
+
header: headerTrait.schema,
|
|
90
|
+
toc: tocTrait.schema,
|
|
91
|
+
links: linksTrait.schema,
|
|
92
|
+
location: locationTrait.schema,
|
|
93
|
+
layout: layoutTrait.schema,
|
|
94
|
+
user: userTrait.schema,
|
|
95
|
+
}
|