@happydesigns/ui 0.15.0 → 0.16.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/app/app.config.ts +5 -5
- package/app/components/article/ArticleGrid.vue +4 -4
- package/app/components/article/ArticleList.vue +4 -4
- package/app/components/footer/FooterCopyright.vue +3 -1
- package/app/components/studio/StudioLoginButton.client.vue +80 -0
- package/app/components/traits/Surround.vue +2 -2
- package/app/composables/useArticleList.ts +8 -19
- package/nuxt.config.ts +3 -3
- package/package.json +2 -2
- package/schemas/traits.ts +9 -4
package/app/app.config.ts
CHANGED
|
@@ -35,9 +35,9 @@ export default defineAppConfig({
|
|
|
35
35
|
article: {
|
|
36
36
|
config: {
|
|
37
37
|
query: {
|
|
38
|
-
fields: ['title', 'description', '
|
|
38
|
+
fields: ['title', 'description', 'published', 'date'],
|
|
39
39
|
order: { field: 'date', direction: 'DESC' },
|
|
40
|
-
where: [{ field: '
|
|
40
|
+
where: [{ field: 'published', operator: '=', value: true }],
|
|
41
41
|
} as QueryConfig,
|
|
42
42
|
categories: {} as Record<string, BadgeProps>,
|
|
43
43
|
breadcrumbs: [],
|
|
@@ -52,9 +52,9 @@ export default defineAppConfig({
|
|
|
52
52
|
event: {
|
|
53
53
|
config: {
|
|
54
54
|
query: {
|
|
55
|
-
fields: ['title', 'description', '
|
|
55
|
+
fields: ['title', 'description', 'published', 'date', 'dateEnd', 'location'],
|
|
56
56
|
order: { field: 'date', direction: 'DESC' },
|
|
57
|
-
where: [{ field: '
|
|
57
|
+
where: [{ field: 'published', operator: '=', value: true }],
|
|
58
58
|
} as QueryConfig,
|
|
59
59
|
categories: {} as Record<string, BadgeProps>,
|
|
60
60
|
breadcrumbs: [],
|
|
@@ -128,7 +128,7 @@ declare module '@nuxt/schema' {
|
|
|
128
128
|
copyrightYear?: number
|
|
129
129
|
/** The name of the copyright holder */
|
|
130
130
|
copyrightHolder?: string
|
|
131
|
-
/**
|
|
131
|
+
/** Optional homepage URL of the copyright holder; omit it to render plain text */
|
|
132
132
|
copyrightHomepage?: string
|
|
133
133
|
}
|
|
134
134
|
/** Social button definitions (e.g. Instagram, Facebook, GitHub) */
|
|
@@ -13,13 +13,13 @@ const props = withDefaults(defineProps<{
|
|
|
13
13
|
where?: ArticleFilter[]
|
|
14
14
|
/** Field to sort by. Set to false to disable default sorting. */
|
|
15
15
|
sort?: { field: string, direction: 'ASC' | 'DESC' } | false
|
|
16
|
-
/**
|
|
17
|
-
|
|
16
|
+
/** Whether to return only published entries. Defaults to true. */
|
|
17
|
+
publishedOnly?: boolean
|
|
18
18
|
/** Optional items per page override */
|
|
19
19
|
itemsPerPage?: number
|
|
20
20
|
}>(), {
|
|
21
21
|
sort: undefined,
|
|
22
|
-
|
|
22
|
+
publishedOnly: true,
|
|
23
23
|
})
|
|
24
24
|
|
|
25
25
|
/** Resolve the configuration for this collection using the smart merger */
|
|
@@ -43,7 +43,7 @@ const { data, status: fetchStatus } = await useArticleList({
|
|
|
43
43
|
collection: () => props.collection || 'article' as C,
|
|
44
44
|
where: () => props.where,
|
|
45
45
|
sort: () => props.sort,
|
|
46
|
-
|
|
46
|
+
publishedOnly: () => props.publishedOnly,
|
|
47
47
|
})
|
|
48
48
|
|
|
49
49
|
const hasArticles = computed(() => Boolean(data.value?.articles.length))
|
|
@@ -14,13 +14,13 @@ const props = withDefaults(defineProps<{
|
|
|
14
14
|
where?: ArticleFilter[]
|
|
15
15
|
/** Field to sort by. Set to false to disable default sorting. */
|
|
16
16
|
sort?: { field: string, direction: 'ASC' | 'DESC' } | false
|
|
17
|
-
/**
|
|
18
|
-
|
|
17
|
+
/** Whether to return only published entries. Defaults to true. */
|
|
18
|
+
publishedOnly?: boolean
|
|
19
19
|
/** Optional items per page override */
|
|
20
20
|
itemsPerPage?: number
|
|
21
21
|
}>(), {
|
|
22
22
|
sort: undefined,
|
|
23
|
-
|
|
23
|
+
publishedOnly: true,
|
|
24
24
|
})
|
|
25
25
|
|
|
26
26
|
/** Resolve the configuration for this collection using the smart merger */
|
|
@@ -69,7 +69,7 @@ const categories = computed(() => {
|
|
|
69
69
|
:collection="props.collection"
|
|
70
70
|
:where="props.where"
|
|
71
71
|
:sort="props.sort"
|
|
72
|
-
:
|
|
72
|
+
:published-only="props.publishedOnly"
|
|
73
73
|
:items-per-page="props.itemsPerPage"
|
|
74
74
|
>
|
|
75
75
|
<template v-for="(_, name) in $slots" #[name]="slotData">
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
const props = defineProps<{
|
|
3
3
|
copyrightYear?: number
|
|
4
4
|
copyrightHolder?: string
|
|
5
|
+
/** Optional URL for the copyright holder. When omitted, the holder is rendered as plain text. */
|
|
5
6
|
copyrightHomepage?: string
|
|
6
7
|
}>()
|
|
7
8
|
|
|
@@ -26,9 +27,10 @@ const copyrightHomepage = props.copyrightHomepage ?? copyright?.copyrightHomepag
|
|
|
26
27
|
<template v-else>
|
|
27
28
|
<p class="text-muted text-sm">
|
|
28
29
|
Copyright © {{ copyrightYear }}
|
|
29
|
-
<ULink
|
|
30
|
+
<ULink v-if="copyrightHomepage" :to="copyrightHomepage">
|
|
30
31
|
{{ copyrightHolder }}
|
|
31
32
|
</ULink>
|
|
33
|
+
<span v-else>{{ copyrightHolder }}</span>
|
|
32
34
|
</p>
|
|
33
35
|
</template>
|
|
34
36
|
</div>
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { StudioUser } from 'nuxt-studio/app'
|
|
3
|
+
|
|
4
|
+
withDefaults(defineProps<{
|
|
5
|
+
/** Accessible label for the icon-only button. */
|
|
6
|
+
ariaLabel?: string
|
|
7
|
+
/** Icon rendered by the underlying UButton. */
|
|
8
|
+
icon?: string
|
|
9
|
+
/** Optional visible button label. */
|
|
10
|
+
label?: string
|
|
11
|
+
}>(), {
|
|
12
|
+
ariaLabel: 'Open Nuxt Studio',
|
|
13
|
+
icon: 'i-lucide-log-in',
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
interface StudioSession {
|
|
17
|
+
user?: StudioUser | null
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const runtimeConfig = useRuntimeConfig()
|
|
21
|
+
const sessionCheckCookie = useCookie<string | null>('studio-session-check')
|
|
22
|
+
const sessionUser = ref<StudioUser | null | undefined>()
|
|
23
|
+
|
|
24
|
+
const studio = computed(() => runtimeConfig.public.studio)
|
|
25
|
+
const studioRoute = computed(() => studio.value.route || '/_studio')
|
|
26
|
+
|
|
27
|
+
onMounted(async () => {
|
|
28
|
+
if (studio.value.dev) {
|
|
29
|
+
return
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (String(sessionCheckCookie.value) !== 'true') {
|
|
33
|
+
sessionUser.value = null
|
|
34
|
+
return
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
try {
|
|
38
|
+
const session = await $fetch('/__nuxt_studio/auth/session') as StudioSession
|
|
39
|
+
sessionUser.value = session.user ?? null
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
sessionUser.value = null
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (!sessionUser.value?.email) {
|
|
46
|
+
sessionCheckCookie.value = null
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
const isLoggedIn = computed(() => {
|
|
51
|
+
if (studio.value.dev) {
|
|
52
|
+
return true
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (String(sessionCheckCookie.value) !== 'true') {
|
|
56
|
+
return false
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (sessionUser.value === undefined) {
|
|
60
|
+
return true
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return Boolean(sessionUser.value?.email)
|
|
64
|
+
})
|
|
65
|
+
</script>
|
|
66
|
+
|
|
67
|
+
<template>
|
|
68
|
+
<UButton
|
|
69
|
+
v-if="!isLoggedIn"
|
|
70
|
+
:to="studioRoute"
|
|
71
|
+
external
|
|
72
|
+
:aria-label="ariaLabel"
|
|
73
|
+
:icon="icon"
|
|
74
|
+
:label="label"
|
|
75
|
+
color="neutral"
|
|
76
|
+
variant="outline"
|
|
77
|
+
size="sm"
|
|
78
|
+
class="fixed bottom-2 left-2 z-50 print:hidden"
|
|
79
|
+
/>
|
|
80
|
+
</template>
|
|
@@ -21,9 +21,9 @@ const { data: surround } = await useAsyncData(
|
|
|
21
21
|
const colName = collection.value as any
|
|
22
22
|
const qc = props.query || {}
|
|
23
23
|
|
|
24
|
-
const fields = (qc.fields || ['title', 'description', '
|
|
24
|
+
const fields = (qc.fields || ['title', 'description', 'published']) as any
|
|
25
25
|
const order = qc.order
|
|
26
|
-
const where = qc.where || [{ field: '
|
|
26
|
+
const where = qc.where || [{ field: 'published', operator: '=', value: true }]
|
|
27
27
|
|
|
28
28
|
let query = queryCollectionItemSurroundings(colName, path.value, { fields })
|
|
29
29
|
|
|
@@ -20,8 +20,8 @@ export interface UseArticleListOptions<C extends keyof PageCollections = 'articl
|
|
|
20
20
|
where?: MaybeRefOrGetter<ArticleFilter[] | undefined>
|
|
21
21
|
/** Field to sort by. Set to false to disable default sorting. Defaults to { field: 'date', direction: 'DESC' }. */
|
|
22
22
|
sort?: MaybeRefOrGetter<{ field: string, direction: 'ASC' | 'DESC' } | false | undefined>
|
|
23
|
-
/**
|
|
24
|
-
|
|
23
|
+
/** Whether to return only published entries. Defaults to true. */
|
|
24
|
+
publishedOnly?: MaybeRefOrGetter<boolean | undefined>
|
|
25
25
|
/** Whether the list should load lazily during client-side navigation. Defaults to false. */
|
|
26
26
|
lazy?: MaybeRefOrGetter<boolean | undefined>
|
|
27
27
|
}
|
|
@@ -45,8 +45,8 @@ export function useArticleList<C extends keyof PageCollections = 'article'>(opti
|
|
|
45
45
|
if (w)
|
|
46
46
|
return w
|
|
47
47
|
|
|
48
|
-
// Fallback to config where but filter out
|
|
49
|
-
return config.value.query?.where?.filter(f => f.field !== '
|
|
48
|
+
// Fallback to config where but filter out publication if handled separately
|
|
49
|
+
return config.value.query?.where?.filter(f => f.field !== 'published') || []
|
|
50
50
|
})
|
|
51
51
|
|
|
52
52
|
const sort = computed(() => {
|
|
@@ -57,21 +57,10 @@ export function useArticleList<C extends keyof PageCollections = 'article'>(opti
|
|
|
57
57
|
return config.value.query?.order
|
|
58
58
|
})
|
|
59
59
|
|
|
60
|
-
const
|
|
61
|
-
const s = toValue(options.status)
|
|
62
|
-
if (s === false)
|
|
63
|
-
return false
|
|
64
|
-
|
|
65
|
-
if (s)
|
|
66
|
-
return s
|
|
67
|
-
|
|
68
|
-
// Try to find status in config where
|
|
69
|
-
const statusFilter = config.value.query?.where?.find(f => f.field === 'status')
|
|
70
|
-
return statusFilter?.value || 'published'
|
|
71
|
-
})
|
|
60
|
+
const publishedOnly = computed(() => toValue(options.publishedOnly) ?? true)
|
|
72
61
|
|
|
73
62
|
// The key must be reactive and stable
|
|
74
|
-
const queryKey = computed(() => `${String(collection.value)}-list-${page.value}-${itemsPerPage.value}-${category.value || 'all'}-${labelAll.value}-${JSON.stringify(where.value)}-${JSON.stringify(sort.value)}-${
|
|
63
|
+
const queryKey = computed(() => `${String(collection.value)}-list-${page.value}-${itemsPerPage.value}-${category.value || 'all'}-${labelAll.value}-${JSON.stringify(where.value)}-${JSON.stringify(sort.value)}-${publishedOnly.value}`)
|
|
75
64
|
|
|
76
65
|
return useAsyncData(queryKey, async () => {
|
|
77
66
|
// We cast the query to a version that includes the standard article fields
|
|
@@ -82,8 +71,8 @@ export function useArticleList<C extends keyof PageCollections = 'article'>(opti
|
|
|
82
71
|
const getDataQuery = () => {
|
|
83
72
|
let query = queryCollection(collection.value) as unknown as ArticleQueryBuilder
|
|
84
73
|
|
|
85
|
-
if (
|
|
86
|
-
query = query.where('
|
|
74
|
+
if (publishedOnly.value) {
|
|
75
|
+
query = query.where('published', '=', true)
|
|
87
76
|
}
|
|
88
77
|
|
|
89
78
|
if (category.value && category.value !== labelAll.value) {
|
package/nuxt.config.ts
CHANGED
|
@@ -34,7 +34,7 @@ export default defineNuxtConfig({
|
|
|
34
34
|
dates: {},
|
|
35
35
|
authors: {},
|
|
36
36
|
category: {},
|
|
37
|
-
|
|
37
|
+
published: {},
|
|
38
38
|
header: {},
|
|
39
39
|
toc: {},
|
|
40
40
|
links: {},
|
|
@@ -52,11 +52,11 @@ export default defineNuxtConfig({
|
|
|
52
52
|
// Collection variants — extends chains defined here for graph generation
|
|
53
53
|
snippet: {},
|
|
54
54
|
article: {
|
|
55
|
-
extends: ['dates', 'authors', 'category', '
|
|
55
|
+
extends: ['dates', 'authors', 'category', 'published', 'header', 'toc', 'surround', 'copyButton', 'separator', 'backButton'],
|
|
56
56
|
config: {},
|
|
57
57
|
},
|
|
58
58
|
event: {
|
|
59
|
-
extends: ['dates', 'location', 'category', 'links', '
|
|
59
|
+
extends: ['dates', 'location', 'category', 'links', 'published', 'header', 'toc', 'surround', 'copyButton', 'separator', 'backButton'],
|
|
60
60
|
config: {},
|
|
61
61
|
},
|
|
62
62
|
page: {
|
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.16.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"packageManager": "pnpm@11.11.0",
|
|
7
7
|
"author": "happydesigns",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"cross-env": "^10.1.0",
|
|
60
60
|
"docus": "5.12.3",
|
|
61
61
|
"eslint": "^10.6.0",
|
|
62
|
-
"nuxt": "^4.
|
|
62
|
+
"nuxt": "^4.5.0",
|
|
63
63
|
"typescript": "^6.0.3",
|
|
64
64
|
"vitest": "^4.1.10",
|
|
65
65
|
"vue-tsc": "^3.3.7",
|
package/schemas/traits.ts
CHANGED
|
@@ -20,9 +20,9 @@ export const categoryTrait = {
|
|
|
20
20
|
}),
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
export const
|
|
23
|
+
export const publishedTrait = {
|
|
24
24
|
schema: z.object({
|
|
25
|
-
|
|
25
|
+
published: z.boolean().default(true),
|
|
26
26
|
}),
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -67,7 +67,12 @@ export const userTrait = {
|
|
|
67
67
|
name: z.string().optional(),
|
|
68
68
|
description: z.string().optional(),
|
|
69
69
|
to: z.string().optional(),
|
|
70
|
-
avatar:
|
|
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(),
|
|
71
76
|
socials: z.array(z.object({
|
|
72
77
|
name: z.string(),
|
|
73
78
|
url: z.url(),
|
|
@@ -80,7 +85,7 @@ export const variantSchemas = {
|
|
|
80
85
|
dates: datesTrait.schema,
|
|
81
86
|
authors: authorsTrait.schema,
|
|
82
87
|
category: categoryTrait.schema,
|
|
83
|
-
|
|
88
|
+
published: publishedTrait.schema,
|
|
84
89
|
header: headerTrait.schema,
|
|
85
90
|
toc: tocTrait.schema,
|
|
86
91
|
links: linksTrait.schema,
|