@happydesigns/ui 0.13.5 → 0.14.0
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/README.md +94 -94
- package/app/app.config.ts +168 -169
- package/app/app.vue +11 -0
- package/app/components/article/ArticleGrid.vue +125 -149
- package/app/components/article/ArticleHeaderBody.vue +20 -20
- package/app/components/article/ArticleHeadlineMeta.vue +26 -26
- package/app/components/article/ArticleList.vue +80 -95
- package/app/components/article/ArticlePage.vue +15 -14
- package/app/components/footer/FooterColumnHeading.vue +5 -5
- package/app/components/footer/FooterCopyright.vue +29 -29
- package/app/components/traits/Authors.vue +19 -20
- package/app/components/traits/BackButton.vue +15 -26
- package/app/components/traits/Category.vue +9 -9
- package/app/components/traits/CopyButton.vue +32 -39
- package/app/components/traits/Dates.vue +20 -20
- package/app/components/traits/Links.vue +17 -17
- package/app/components/traits/Location.vue +20 -20
- package/app/components/traits/Separator.vue +21 -26
- package/app/components/traits/SeparatorButtons.vue +53 -56
- package/app/components/traits/Surround.vue +48 -60
- package/app/components/traits/Toc.vue +16 -16
- package/app/composables/useArticleList.ts +24 -26
- package/app/composables/useArticleListQuery.ts +54 -0
- package/app/composables/useCategoryBadge.ts +27 -27
- package/app/composables/useClipboard.ts +26 -26
- package/app/composables/usePageContent.ts +18 -18
- package/app/composables/usePageSeo.ts +30 -30
- package/app/layouts/article.vue +117 -125
- package/app/layouts/content.vue +57 -65
- package/app/layouts/default.vue +3 -12
- package/app/types/config.ts +13 -6
- package/content.config.ts +6 -6
- package/nuxt.config.ts +80 -80
- package/package.json +3 -3
- package/schemas/collections.ts +46 -46
- package/schemas/index.ts +2 -2
- package/schemas/traits.ts +90 -90
package/app/layouts/content.vue
CHANGED
|
@@ -1,67 +1,59 @@
|
|
|
1
|
-
<script setup lang="ts" generic="C extends 'page' = 'page'">
|
|
2
|
-
import type { Collections } from '@nuxt/content'
|
|
3
|
-
|
|
4
|
-
const {
|
|
5
|
-
path,
|
|
6
|
-
collection = 'page' as C,
|
|
7
|
-
} = defineProps<{
|
|
8
|
-
path?: string
|
|
9
|
-
collection?: C
|
|
10
|
-
}>()
|
|
11
|
-
|
|
12
|
-
const appConfig = useAppConfig()
|
|
13
|
-
const route = useRoute()
|
|
14
|
-
|
|
15
|
-
const { data: page } = await usePageContent<C, Collections['page']>({
|
|
16
|
-
path: () => path,
|
|
17
|
-
collection: () => collection,
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
const { has } = useVariant(collection)
|
|
21
|
-
const hasHeader = has('header')
|
|
22
|
-
const hasToc = has('toc')
|
|
23
|
-
|
|
24
|
-
if (!page.value) {
|
|
25
|
-
throw createError({
|
|
26
|
-
statusCode: 404,
|
|
27
|
-
statusMessage: `${collection} ${path || route.path} not found`,
|
|
28
|
-
fatal: true,
|
|
29
|
-
})
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
usePageSeo(page)
|
|
33
|
-
|
|
34
|
-
const renderToc = computed(() => hasToc.value && page.value?.toc !== false)
|
|
35
|
-
const header = computed(() => resolvePageHeader(page.value))
|
|
36
|
-
</script>
|
|
37
|
-
|
|
1
|
+
<script setup lang="ts" generic="C extends 'page' = 'page'">
|
|
2
|
+
import type { Collections } from '@nuxt/content'
|
|
3
|
+
|
|
4
|
+
const {
|
|
5
|
+
path,
|
|
6
|
+
collection = 'page' as C,
|
|
7
|
+
} = defineProps<{
|
|
8
|
+
path?: string
|
|
9
|
+
collection?: C
|
|
10
|
+
}>()
|
|
11
|
+
|
|
12
|
+
const appConfig = useAppConfig()
|
|
13
|
+
const route = useRoute()
|
|
14
|
+
|
|
15
|
+
const { data: page } = await usePageContent<C, Collections['page']>({
|
|
16
|
+
path: () => path,
|
|
17
|
+
collection: () => collection,
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
const { has } = useVariant(collection)
|
|
21
|
+
const hasHeader = has('header')
|
|
22
|
+
const hasToc = has('toc')
|
|
23
|
+
|
|
24
|
+
if (!page.value) {
|
|
25
|
+
throw createError({
|
|
26
|
+
statusCode: 404,
|
|
27
|
+
statusMessage: `${collection} ${path || route.path} not found`,
|
|
28
|
+
fatal: true,
|
|
29
|
+
})
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
usePageSeo(page)
|
|
33
|
+
|
|
34
|
+
const renderToc = computed(() => hasToc.value && page.value?.toc !== false)
|
|
35
|
+
const header = computed(() => resolvePageHeader(page.value))
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
38
|
<template>
|
|
39
|
-
<
|
|
40
|
-
<
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
/>
|
|
60
|
-
</template>
|
|
61
|
-
</UPage>
|
|
62
|
-
</UContainer>
|
|
63
|
-
</UMain>
|
|
64
|
-
|
|
65
|
-
<AppFooter />
|
|
66
|
-
</div>
|
|
39
|
+
<UContainer v-if="page">
|
|
40
|
+
<UPage>
|
|
41
|
+
<UPageHeader
|
|
42
|
+
v-if="hasHeader && header"
|
|
43
|
+
v-bind="header"
|
|
44
|
+
/>
|
|
45
|
+
|
|
46
|
+
<UPageBody>
|
|
47
|
+
<slot />
|
|
48
|
+
</UPageBody>
|
|
49
|
+
|
|
50
|
+
<template #right>
|
|
51
|
+
<UContentToc
|
|
52
|
+
v-if="renderToc && page.body?.toc?.links?.length"
|
|
53
|
+
:links="page.body.toc.links"
|
|
54
|
+
:title="page.body.toc.title || appConfig.app.toc?.title"
|
|
55
|
+
/>
|
|
56
|
+
</template>
|
|
57
|
+
</UPage>
|
|
58
|
+
</UContainer>
|
|
67
59
|
</template>
|
package/app/layouts/default.vue
CHANGED
package/app/types/config.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import type { SQLOperator } from '@nuxt/content'
|
|
2
|
+
import type { ButtonProps } from '@nuxt/ui'
|
|
3
|
+
|
|
4
|
+
export type ActionButton = ButtonProps & {
|
|
5
|
+
/** Built-in type for a dynamic GitHub link (URL resolved from app.meta.github) */
|
|
6
|
+
type?: 'github-edit' | 'report-github-issue'
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface QueryConfig {
|
|
10
|
+
fields?: string[]
|
|
11
|
+
where?: { field: string, operator: SQLOperator, value?: unknown }[]
|
|
12
|
+
order?: { field: string, direction: 'ASC' | 'DESC' } | false
|
|
13
|
+
}
|
package/content.config.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { defineContentConfig } from '@nuxt/content'
|
|
2
|
-
import { collections } from './schemas'
|
|
3
|
-
|
|
4
|
-
export default defineContentConfig({
|
|
5
|
-
collections,
|
|
6
|
-
})
|
|
1
|
+
import { defineContentConfig } from '@nuxt/content'
|
|
2
|
+
import { collections } from './schemas'
|
|
3
|
+
|
|
4
|
+
export default defineContentConfig({
|
|
5
|
+
collections,
|
|
6
|
+
})
|
package/nuxt.config.ts
CHANGED
|
@@ -1,80 +1,80 @@
|
|
|
1
|
-
import { dirname } from 'node:path'
|
|
2
|
-
import { fileURLToPath } from 'node:url'
|
|
3
|
-
import { resolve } from 'pathe'
|
|
4
|
-
|
|
5
|
-
const currentDir: string = dirname(fileURLToPath(import.meta.url))
|
|
6
|
-
|
|
7
|
-
// https://nuxt.com/docs/api/configuration/nuxt-config
|
|
8
|
-
export default defineNuxtConfig({
|
|
9
|
-
|
|
10
|
-
$meta: {
|
|
11
|
-
name: '@happydesigns/ui',
|
|
12
|
-
},
|
|
13
|
-
|
|
14
|
-
components: [
|
|
15
|
-
{ path: './components', pathPrefix: false, prefix: 'H' },
|
|
16
|
-
],
|
|
17
|
-
|
|
18
|
-
css: [
|
|
19
|
-
resolve(currentDir, './app/assets/css/main.css'),
|
|
20
|
-
],
|
|
21
|
-
|
|
22
|
-
devtools: { enabled: true },
|
|
23
|
-
|
|
24
|
-
modules: [
|
|
25
|
-
'@nuxt/eslint',
|
|
26
|
-
'@happydesigns/nuxt-variants',
|
|
27
|
-
'@nuxt/ui',
|
|
28
|
-
'@nuxt/content',
|
|
29
|
-
'nuxt-studio',
|
|
30
|
-
],
|
|
31
|
-
|
|
32
|
-
variants: {
|
|
33
|
-
registry: {
|
|
34
|
-
// Data features — schema only, no config
|
|
35
|
-
dates: {},
|
|
36
|
-
authors: {},
|
|
37
|
-
category: {},
|
|
38
|
-
status: {},
|
|
39
|
-
header: {},
|
|
40
|
-
toc: {},
|
|
41
|
-
links: {},
|
|
42
|
-
location: {},
|
|
43
|
-
layout: {},
|
|
44
|
-
separatorButtons: {},
|
|
45
|
-
|
|
46
|
-
// UI features — config defined in app.config.ts
|
|
47
|
-
user: {},
|
|
48
|
-
backButton: {},
|
|
49
|
-
copyButton: {},
|
|
50
|
-
separator: {},
|
|
51
|
-
surround: {},
|
|
52
|
-
|
|
53
|
-
// Collection variants — extends chains defined here for graph generation
|
|
54
|
-
snippet: {},
|
|
55
|
-
article: {
|
|
56
|
-
extends: ['dates', 'authors', 'category', 'status', 'header', 'toc', 'surround', 'copyButton', 'separator', 'backButton', 'user'],
|
|
57
|
-
config: {},
|
|
58
|
-
},
|
|
59
|
-
event: {
|
|
60
|
-
extends: ['dates', 'location', 'category', 'links', 'status', 'header', 'toc', 'surround', 'copyButton', 'separator', 'backButton', 'user'],
|
|
61
|
-
config: {},
|
|
62
|
-
},
|
|
63
|
-
page: {
|
|
64
|
-
extends: ['layout', 'header', 'toc'],
|
|
65
|
-
config: {},
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
eslint: {
|
|
71
|
-
config: {
|
|
72
|
-
stylistic: true,
|
|
73
|
-
standalone: false,
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
|
|
77
|
-
studio: {
|
|
78
|
-
dev: true,
|
|
79
|
-
},
|
|
80
|
-
})
|
|
1
|
+
import { dirname } from 'node:path'
|
|
2
|
+
import { fileURLToPath } from 'node:url'
|
|
3
|
+
import { resolve } from 'pathe'
|
|
4
|
+
|
|
5
|
+
const currentDir: string = dirname(fileURLToPath(import.meta.url))
|
|
6
|
+
|
|
7
|
+
// https://nuxt.com/docs/api/configuration/nuxt-config
|
|
8
|
+
export default defineNuxtConfig({
|
|
9
|
+
|
|
10
|
+
$meta: {
|
|
11
|
+
name: '@happydesigns/ui',
|
|
12
|
+
},
|
|
13
|
+
|
|
14
|
+
components: [
|
|
15
|
+
{ path: './components', pathPrefix: false, prefix: 'H' },
|
|
16
|
+
],
|
|
17
|
+
|
|
18
|
+
css: [
|
|
19
|
+
resolve(currentDir, './app/assets/css/main.css'),
|
|
20
|
+
],
|
|
21
|
+
|
|
22
|
+
devtools: { enabled: true },
|
|
23
|
+
|
|
24
|
+
modules: [
|
|
25
|
+
'@nuxt/eslint',
|
|
26
|
+
'@happydesigns/nuxt-variants',
|
|
27
|
+
'@nuxt/ui',
|
|
28
|
+
'@nuxt/content',
|
|
29
|
+
'nuxt-studio',
|
|
30
|
+
],
|
|
31
|
+
|
|
32
|
+
variants: {
|
|
33
|
+
registry: {
|
|
34
|
+
// Data features — schema only, no config
|
|
35
|
+
dates: {},
|
|
36
|
+
authors: {},
|
|
37
|
+
category: {},
|
|
38
|
+
status: {},
|
|
39
|
+
header: {},
|
|
40
|
+
toc: {},
|
|
41
|
+
links: {},
|
|
42
|
+
location: {},
|
|
43
|
+
layout: {},
|
|
44
|
+
separatorButtons: {},
|
|
45
|
+
|
|
46
|
+
// UI features — config defined in app.config.ts
|
|
47
|
+
user: {},
|
|
48
|
+
backButton: {},
|
|
49
|
+
copyButton: {},
|
|
50
|
+
separator: {},
|
|
51
|
+
surround: {},
|
|
52
|
+
|
|
53
|
+
// Collection variants — extends chains defined here for graph generation
|
|
54
|
+
snippet: {},
|
|
55
|
+
article: {
|
|
56
|
+
extends: ['dates', 'authors', 'category', 'status', 'header', 'toc', 'surround', 'copyButton', 'separator', 'backButton', 'user'],
|
|
57
|
+
config: {},
|
|
58
|
+
},
|
|
59
|
+
event: {
|
|
60
|
+
extends: ['dates', 'location', 'category', 'links', 'status', 'header', 'toc', 'surround', 'copyButton', 'separator', 'backButton', 'user'],
|
|
61
|
+
config: {},
|
|
62
|
+
},
|
|
63
|
+
page: {
|
|
64
|
+
extends: ['layout', 'header', 'toc'],
|
|
65
|
+
config: {},
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
eslint: {
|
|
71
|
+
config: {
|
|
72
|
+
stylistic: true,
|
|
73
|
+
standalone: false,
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
|
|
77
|
+
studio: {
|
|
78
|
+
dev: true,
|
|
79
|
+
},
|
|
80
|
+
})
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@happydesigns/ui",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.14.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"packageManager": "pnpm@10.33.0",
|
|
7
7
|
"author": "happydesigns",
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"release:beta": "changelogen --release --versionSuffix beta.0"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
+
"@happydesigns/nuxt-variants": "^0.0.6",
|
|
37
38
|
"@iconify-json/heroicons": "^1.2.3",
|
|
38
39
|
"@iconify-json/lucide": "^1.2.101",
|
|
39
40
|
"@iconify-json/simple-icons": "^1.2.76",
|
|
@@ -45,7 +46,6 @@
|
|
|
45
46
|
"devDependencies": {
|
|
46
47
|
"@antfu/eslint-config": "^8.0.0",
|
|
47
48
|
"@antfu/ni": "^30.0.0",
|
|
48
|
-
"@happydesigns/nuxt-variants": "^0.0.5",
|
|
49
49
|
"@nuxt/eslint": "^1.15.2",
|
|
50
50
|
"changelogen": "^0.6.2",
|
|
51
51
|
"cross-env": "^10.1.0",
|
|
@@ -57,4 +57,4 @@
|
|
|
57
57
|
"resolutions": {
|
|
58
58
|
"@happydesigns/ui": "workspace:*"
|
|
59
59
|
}
|
|
60
|
-
}
|
|
60
|
+
}
|
package/schemas/collections.ts
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
import { mergeVariantSchemas } from '@happydesigns/nuxt-variants/schemas'
|
|
2
|
-
import { defineCollection } from '@nuxt/content'
|
|
3
|
-
import { variantSchemas } from './traits'
|
|
4
|
-
|
|
5
|
-
export const collections = {
|
|
6
|
-
snippet: defineCollection({
|
|
7
|
-
type: 'page',
|
|
8
|
-
source: {
|
|
9
|
-
include: 'snippets/**/*.{md,yaml}',
|
|
10
|
-
prefix: '/snippets',
|
|
11
|
-
},
|
|
12
|
-
}),
|
|
13
|
-
|
|
14
|
-
article: defineCollection({
|
|
15
|
-
type: 'page',
|
|
16
|
-
source: {
|
|
17
|
-
include: 'articles/**/*.{md,yaml}',
|
|
18
|
-
prefix: '/articles',
|
|
19
|
-
},
|
|
20
|
-
schema: mergeVariantSchemas(['article'], variantSchemas),
|
|
21
|
-
}),
|
|
22
|
-
|
|
23
|
-
event: defineCollection({
|
|
24
|
-
type: 'page',
|
|
25
|
-
source: {
|
|
26
|
-
include: 'events/**/*.{md,yaml}',
|
|
27
|
-
prefix: '/events',
|
|
28
|
-
},
|
|
29
|
-
schema: mergeVariantSchemas(['event'], variantSchemas),
|
|
30
|
-
}),
|
|
31
|
-
|
|
32
|
-
page: defineCollection({
|
|
33
|
-
type: 'page',
|
|
34
|
-
source: {
|
|
35
|
-
include: 'pages/**/*.{md,yaml}',
|
|
36
|
-
prefix: '/',
|
|
37
|
-
},
|
|
38
|
-
schema: mergeVariantSchemas(['page'], variantSchemas),
|
|
39
|
-
}),
|
|
40
|
-
|
|
41
|
-
user: defineCollection({
|
|
42
|
-
type: 'data',
|
|
43
|
-
source: 'users/**/*.{md,yaml}',
|
|
44
|
-
schema: mergeVariantSchemas(['user'], variantSchemas),
|
|
45
|
-
}),
|
|
46
|
-
}
|
|
1
|
+
import { mergeVariantSchemas } from '@happydesigns/nuxt-variants/schemas'
|
|
2
|
+
import { defineCollection } from '@nuxt/content'
|
|
3
|
+
import { variantSchemas } from './traits'
|
|
4
|
+
|
|
5
|
+
export const collections = {
|
|
6
|
+
snippet: defineCollection({
|
|
7
|
+
type: 'page',
|
|
8
|
+
source: {
|
|
9
|
+
include: 'snippets/**/*.{md,yaml}',
|
|
10
|
+
prefix: '/snippets',
|
|
11
|
+
},
|
|
12
|
+
}),
|
|
13
|
+
|
|
14
|
+
article: defineCollection({
|
|
15
|
+
type: 'page',
|
|
16
|
+
source: {
|
|
17
|
+
include: 'articles/**/*.{md,yaml}',
|
|
18
|
+
prefix: '/articles',
|
|
19
|
+
},
|
|
20
|
+
schema: mergeVariantSchemas(['article'], variantSchemas),
|
|
21
|
+
}),
|
|
22
|
+
|
|
23
|
+
event: defineCollection({
|
|
24
|
+
type: 'page',
|
|
25
|
+
source: {
|
|
26
|
+
include: 'events/**/*.{md,yaml}',
|
|
27
|
+
prefix: '/events',
|
|
28
|
+
},
|
|
29
|
+
schema: mergeVariantSchemas(['event'], variantSchemas),
|
|
30
|
+
}),
|
|
31
|
+
|
|
32
|
+
page: defineCollection({
|
|
33
|
+
type: 'page',
|
|
34
|
+
source: {
|
|
35
|
+
include: 'pages/**/*.{md,yaml}',
|
|
36
|
+
prefix: '/',
|
|
37
|
+
},
|
|
38
|
+
schema: mergeVariantSchemas(['page'], variantSchemas),
|
|
39
|
+
}),
|
|
40
|
+
|
|
41
|
+
user: defineCollection({
|
|
42
|
+
type: 'data',
|
|
43
|
+
source: 'users/**/*.{md,yaml}',
|
|
44
|
+
schema: mergeVariantSchemas(['user'], variantSchemas),
|
|
45
|
+
}),
|
|
46
|
+
}
|
package/schemas/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './collections'
|
|
2
|
-
export * from './traits'
|
|
1
|
+
export * from './collections'
|
|
2
|
+
export * from './traits'
|
package/schemas/traits.ts
CHANGED
|
@@ -1,90 +1,90 @@
|
|
|
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 statusTrait = {
|
|
24
|
-
schema: z.object({
|
|
25
|
-
status: z.enum(['published', 'draft', 'archived']).default('published'),
|
|
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', '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: property(z.object({})).inherit('@nuxt/ui/components/Avatar.vue').optional(),
|
|
71
|
-
socials: z.array(z.object({
|
|
72
|
-
name: z.string(),
|
|
73
|
-
url: z.url(),
|
|
74
|
-
})).optional(),
|
|
75
|
-
email: z.email().optional(),
|
|
76
|
-
}),
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export const variantSchemas = {
|
|
80
|
-
dates: datesTrait.schema,
|
|
81
|
-
authors: authorsTrait.schema,
|
|
82
|
-
category: categoryTrait.schema,
|
|
83
|
-
status: statusTrait.schema,
|
|
84
|
-
header: headerTrait.schema,
|
|
85
|
-
toc: tocTrait.schema,
|
|
86
|
-
links: linksTrait.schema,
|
|
87
|
-
location: locationTrait.schema,
|
|
88
|
-
layout: layoutTrait.schema,
|
|
89
|
-
user: userTrait.schema,
|
|
90
|
-
}
|
|
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 statusTrait = {
|
|
24
|
+
schema: z.object({
|
|
25
|
+
status: z.enum(['published', 'draft', 'archived']).default('published'),
|
|
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', '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: property(z.object({})).inherit('@nuxt/ui/components/Avatar.vue').optional(),
|
|
71
|
+
socials: z.array(z.object({
|
|
72
|
+
name: z.string(),
|
|
73
|
+
url: z.url(),
|
|
74
|
+
})).optional(),
|
|
75
|
+
email: z.email().optional(),
|
|
76
|
+
}),
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export const variantSchemas = {
|
|
80
|
+
dates: datesTrait.schema,
|
|
81
|
+
authors: authorsTrait.schema,
|
|
82
|
+
category: categoryTrait.schema,
|
|
83
|
+
status: statusTrait.schema,
|
|
84
|
+
header: headerTrait.schema,
|
|
85
|
+
toc: tocTrait.schema,
|
|
86
|
+
links: linksTrait.schema,
|
|
87
|
+
location: locationTrait.schema,
|
|
88
|
+
layout: layoutTrait.schema,
|
|
89
|
+
user: userTrait.schema,
|
|
90
|
+
}
|