@happydesigns/ui 0.15.1 → 0.17.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 +64 -53
- package/app/app.config.ts +138 -165
- package/app/app.vue +0 -2
- package/app/assets/css/styles.css +38 -0
- package/app/components/Carousel.vue +33 -0
- package/app/components/{content/Snippet.vue → Snippet.vue} +6 -2
- package/app/components/article/ArticleGrid.vue +4 -4
- package/app/components/article/ArticleGridDate.vue +19 -16
- package/app/components/article/ArticleHeaderBody.vue +26 -20
- package/app/components/article/ArticleHeadlineMeta.vue +37 -26
- package/app/components/article/ArticleList.vue +5 -5
- package/app/components/article/ArticlePage.vue +1 -1
- package/app/components/footer/FooterColumns.vue +60 -101
- package/app/components/search/ContentSearch.client.vue +59 -0
- package/app/components/studio/StudioLoginButton.client.vue +11 -3
- package/app/components/traits/Category.vue +1 -1
- package/app/components/traits/CopyButton.vue +40 -32
- package/app/components/traits/Links.vue +21 -17
- package/app/components/traits/Surround.vue +6 -7
- package/app/components/traits/Toc.vue +18 -16
- package/app/composables/useArticleList.ts +37 -46
- package/app/composables/useClipboard.ts +48 -26
- package/app/composables/useContentSearchData.ts +42 -0
- package/app/composables/useNavigationLinks.ts +40 -0
- package/app/composables/usePageContent.ts +1 -3
- package/app/composables/usePageSeo.ts +7 -15
- package/app/internal/pageLayout.ts +7 -0
- package/app/layouts/article.vue +137 -120
- package/app/layouts/content.vue +63 -59
- package/app/types/config.ts +91 -13
- package/app/utils/createContentSearchLoader.ts +45 -0
- package/app/utils/formatDate.ts +1 -1
- package/app/utils/formatDateTime.ts +1 -1
- package/app/utils/isNavigationTargetActive.ts +12 -0
- package/app/utils/resolveUsers.ts +56 -42
- package/nuxt.config.ts +4 -16
- package/package.json +17 -9
- package/schemas/collections.ts +4 -0
- package/schemas/indexes.ts +10 -0
- package/schemas/traits.ts +9 -4
- package/server/api/navigation.json.get.ts +11 -0
- package/server/api/search.json.get.ts +11 -0
- package/server/utils/contentSearch.ts +67 -0
- package/shared/types/app-config.d.ts +23 -0
- package/app/assets/css/main.css +0 -14
- package/app/components/content/Carousel.vue +0 -11
package/app/layouts/content.vue
CHANGED
|
@@ -1,59 +1,63 @@
|
|
|
1
|
-
<script setup lang="ts" generic="C extends 'page' = 'page'">
|
|
2
|
-
import type { Collections } from '@nuxt/content'
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
<
|
|
51
|
-
<
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
1
|
+
<script setup lang="ts" generic="C extends 'page' = 'page'">
|
|
2
|
+
import type { Collections } from '@nuxt/content'
|
|
3
|
+
import { getPageLayoutUi } from '../internal/pageLayout'
|
|
4
|
+
|
|
5
|
+
const {
|
|
6
|
+
path,
|
|
7
|
+
collection = 'page' as C,
|
|
8
|
+
} = defineProps<{
|
|
9
|
+
path?: string
|
|
10
|
+
collection?: C
|
|
11
|
+
}>()
|
|
12
|
+
|
|
13
|
+
const appConfig = useAppConfig()
|
|
14
|
+
const route = useRoute()
|
|
15
|
+
|
|
16
|
+
const { data: page } = await usePageContent<C, Collections['page']>({
|
|
17
|
+
path: () => path,
|
|
18
|
+
collection: () => collection,
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
const { has } = useVariant(collection)
|
|
22
|
+
const hasHeader = has('header')
|
|
23
|
+
const hasToc = has('toc')
|
|
24
|
+
|
|
25
|
+
if (!page.value) {
|
|
26
|
+
throw createError({
|
|
27
|
+
statusCode: 404,
|
|
28
|
+
statusMessage: `${collection} ${path || route.path} not found`,
|
|
29
|
+
fatal: true,
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
usePageSeo(page)
|
|
34
|
+
|
|
35
|
+
const renderToc = computed(() => hasToc.value
|
|
36
|
+
&& page.value?.toc !== false
|
|
37
|
+
&& Boolean(page.value?.body?.toc?.links?.length))
|
|
38
|
+
const pageUi = computed(() => getPageLayoutUi(renderToc.value))
|
|
39
|
+
const header = computed(() => resolvePageHeader(page.value))
|
|
40
|
+
</script>
|
|
41
|
+
|
|
42
|
+
<template>
|
|
43
|
+
<UContainer v-if="page">
|
|
44
|
+
<UPageHeader
|
|
45
|
+
v-if="hasHeader && header"
|
|
46
|
+
v-bind="header"
|
|
47
|
+
/>
|
|
48
|
+
|
|
49
|
+
<UPage :ui="pageUi">
|
|
50
|
+
<UPageBody>
|
|
51
|
+
<slot />
|
|
52
|
+
</UPageBody>
|
|
53
|
+
|
|
54
|
+
<template #right>
|
|
55
|
+
<UContentToc
|
|
56
|
+
v-if="renderToc"
|
|
57
|
+
:links="page.body?.toc?.links"
|
|
58
|
+
:title="page.body?.toc?.title || appConfig.app.toc?.title"
|
|
59
|
+
/>
|
|
60
|
+
</template>
|
|
61
|
+
</UPage>
|
|
62
|
+
</UContainer>
|
|
63
|
+
</template>
|
package/app/types/config.ts
CHANGED
|
@@ -1,13 +1,91 @@
|
|
|
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
|
-
action?: '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
|
-
}
|
|
1
|
+
import type { PageCollections, SQLOperator } from '@nuxt/content'
|
|
2
|
+
import type { ButtonProps, CommandPaletteGroup, ContentSearchLink, FooterColumn, NavigationMenuItem } 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
|
+
action?: '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
|
+
}
|
|
14
|
+
export interface SearchCollectionConfig {
|
|
15
|
+
/** Page collection included in both generated search indexes. */
|
|
16
|
+
name: keyof PageCollections & string
|
|
17
|
+
/** Filters applied before navigation and search sections are generated. */
|
|
18
|
+
where?: QueryConfig['where']
|
|
19
|
+
/** Optional stable ordering for generated entries. */
|
|
20
|
+
order?: QueryConfig['order']
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface SearchConfig {
|
|
24
|
+
title?: string
|
|
25
|
+
description?: string
|
|
26
|
+
placeholder?: string
|
|
27
|
+
resultLimit?: number
|
|
28
|
+
links?: ContentSearchLink[]
|
|
29
|
+
groups?: CommandPaletteGroup[]
|
|
30
|
+
/** Shared-cache policy for dynamic search endpoints. Set to false to disable caching. */
|
|
31
|
+
cache?: false | {
|
|
32
|
+
/** CDN/proxy cache lifetime in seconds. Browser responses always revalidate. */
|
|
33
|
+
sharedMaxAge?: number
|
|
34
|
+
/** Time in seconds a shared cache may serve stale data while refreshing. */
|
|
35
|
+
staleWhileRevalidate?: number
|
|
36
|
+
}
|
|
37
|
+
error?: {
|
|
38
|
+
title?: string
|
|
39
|
+
description?: string
|
|
40
|
+
retryLabel?: string
|
|
41
|
+
}
|
|
42
|
+
/** Opt-in page collections exposed by the generated public search indexes. */
|
|
43
|
+
collections?: SearchCollectionConfig[]
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Consumer-owned app config fields can be added through declaration merging.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* declare module '@happydesigns/ui/types' {
|
|
50
|
+
* interface HAppConfigExtensions {
|
|
51
|
+
* contact?: { email?: string }
|
|
52
|
+
* }
|
|
53
|
+
* }
|
|
54
|
+
*/
|
|
55
|
+
export interface HAppConfigExtensions {}
|
|
56
|
+
|
|
57
|
+
export interface HAppConfigInput extends HAppConfigExtensions {
|
|
58
|
+
meta?: {
|
|
59
|
+
copyright?: {
|
|
60
|
+
copyrightYear?: number
|
|
61
|
+
copyrightHolder?: string
|
|
62
|
+
copyrightHomepage?: string
|
|
63
|
+
}
|
|
64
|
+
socials?: ButtonProps[]
|
|
65
|
+
github?: {
|
|
66
|
+
repo?: string
|
|
67
|
+
branch?: string
|
|
68
|
+
dir?: string
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
links?: {
|
|
72
|
+
header?: NavigationMenuItem[]
|
|
73
|
+
footer?: FooterColumn[]
|
|
74
|
+
}
|
|
75
|
+
search?: SearchConfig
|
|
76
|
+
toc?: { title?: string }
|
|
77
|
+
icons?: Record<string, string>
|
|
78
|
+
date?: {
|
|
79
|
+
locale?: string
|
|
80
|
+
options?: Intl.DateTimeFormatOptions
|
|
81
|
+
datetimeOptions?: Intl.DateTimeFormatOptions
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
export interface HAppConfig extends HAppConfigInput {
|
|
85
|
+
meta: NonNullable<HAppConfigInput['meta']>
|
|
86
|
+
links: NonNullable<HAppConfigInput['links']>
|
|
87
|
+
search: SearchConfig
|
|
88
|
+
toc: NonNullable<HAppConfigInput['toc']>
|
|
89
|
+
icons: Record<string, string>
|
|
90
|
+
date: NonNullable<HAppConfigInput['date']>
|
|
91
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export interface ContentSearchLoaders<TNavigation, TFiles> {
|
|
2
|
+
navigation: () => Promise<TNavigation>
|
|
3
|
+
files: () => Promise<TFiles>
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface ContentSearchLoaderCallbacks<TNavigation, TFiles> {
|
|
7
|
+
success: (navigation: TNavigation, files: TFiles) => void
|
|
8
|
+
error: (error: Error) => void
|
|
9
|
+
pending?: () => void
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function createContentSearchLoader<TNavigation, TFiles>(
|
|
13
|
+
loaders: ContentSearchLoaders<TNavigation, TFiles>,
|
|
14
|
+
callbacks: ContentSearchLoaderCallbacks<TNavigation, TFiles>,
|
|
15
|
+
) {
|
|
16
|
+
let loaded = false
|
|
17
|
+
let pendingRequest: Promise<void> | undefined
|
|
18
|
+
|
|
19
|
+
async function load() {
|
|
20
|
+
if (loaded) {
|
|
21
|
+
return
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (pendingRequest) {
|
|
25
|
+
return pendingRequest
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
callbacks.pending?.()
|
|
29
|
+
pendingRequest = Promise.all([loaders.navigation(), loaders.files()])
|
|
30
|
+
.then(([navigation, files]) => {
|
|
31
|
+
loaded = true
|
|
32
|
+
callbacks.success(navigation, files)
|
|
33
|
+
})
|
|
34
|
+
.catch((cause: unknown) => {
|
|
35
|
+
callbacks.error(cause instanceof Error ? cause : new Error(String(cause)))
|
|
36
|
+
})
|
|
37
|
+
.finally(() => {
|
|
38
|
+
pendingRequest = undefined
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
return pendingRequest
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return { load }
|
|
45
|
+
}
|
package/app/utils/formatDate.ts
CHANGED
|
@@ -16,7 +16,7 @@ export default function formatDate(date?: string | number | Date): string {
|
|
|
16
16
|
|
|
17
17
|
const appConfig = useAppConfig()
|
|
18
18
|
const locale = appConfig.app.date?.locale || 'en'
|
|
19
|
-
const options = appConfig.app.date?.options || {
|
|
19
|
+
const options: Intl.DateTimeFormatOptions = appConfig.app.date?.options as Intl.DateTimeFormatOptions || {
|
|
20
20
|
year: 'numeric',
|
|
21
21
|
month: 'short',
|
|
22
22
|
day: 'numeric',
|
|
@@ -16,7 +16,7 @@ export default function formatDateTime(date?: string | number | Date): string {
|
|
|
16
16
|
|
|
17
17
|
const appConfig = useAppConfig()
|
|
18
18
|
const locale = appConfig.app.date?.locale || 'en'
|
|
19
|
-
const options = appConfig.app.date?.datetimeOptions || {
|
|
19
|
+
const options: Intl.DateTimeFormatOptions = appConfig.app.date?.datetimeOptions as Intl.DateTimeFormatOptions || {
|
|
20
20
|
year: 'numeric',
|
|
21
21
|
month: 'short',
|
|
22
22
|
day: 'numeric',
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function isNavigationTargetActive(currentPath: string, target?: unknown): boolean {
|
|
2
|
+
if (typeof target !== 'string' || !target.startsWith('/') || target.startsWith('//')) {
|
|
3
|
+
return false
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
const targetPath = target.split(/[?#]/, 1)[0] || '/'
|
|
7
|
+
const normalizedCurrent = currentPath === '/' ? '/' : currentPath.replace(/\/+$/, '')
|
|
8
|
+
const normalizedTarget = targetPath === '/' ? '/' : targetPath.replace(/\/+$/, '')
|
|
9
|
+
|
|
10
|
+
return normalizedCurrent === normalizedTarget
|
|
11
|
+
|| (normalizedTarget !== '/' && normalizedCurrent.startsWith(normalizedTarget.concat('/')))
|
|
12
|
+
}
|
|
@@ -1,45 +1,59 @@
|
|
|
1
|
-
import type { UserProps } from '@nuxt/ui'
|
|
2
|
-
|
|
3
|
-
interface UserRecord {
|
|
4
|
-
username: string
|
|
5
|
-
name?: UserProps['name']
|
|
6
|
-
description?: UserProps['description']
|
|
7
|
-
to?: UserProps['to']
|
|
8
|
-
avatar?: UserProps['avatar']
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
interface UserQuery {
|
|
12
|
-
where: (field: 'username', operator: 'IN', value: string[]) => UserQuery
|
|
13
|
-
select: (...fields: Array<keyof UserRecord>) => UserQuery
|
|
14
|
-
all: () => Promise<UserRecord[]>
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Removes the internal collection lookup key before passing a profile to Nuxt UI.
|
|
19
|
-
*/
|
|
20
|
-
export function toUserProps<T extends { username: string }>(
|
|
21
|
-
user: T,
|
|
22
|
-
extraProps: Partial<UserProps> = {},
|
|
23
|
-
) {
|
|
24
|
-
const { username: _lookupKey, ...profile } = user
|
|
25
|
-
|
|
26
|
-
return { ...profile, ...extraProps }
|
|
1
|
+
import type { UserProps } from '@nuxt/ui'
|
|
2
|
+
|
|
3
|
+
interface UserRecord {
|
|
4
|
+
username: string
|
|
5
|
+
name?: UserProps['name']
|
|
6
|
+
description?: UserProps['description']
|
|
7
|
+
to?: UserProps['to']
|
|
8
|
+
avatar?: UserProps['avatar']
|
|
27
9
|
}
|
|
28
10
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
*
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
11
|
+
export type ResolvedUser = Omit<UserRecord, 'username'> & Partial<UserProps>
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Removes the internal collection lookup key before passing a profile to Nuxt UI.
|
|
15
|
+
*/
|
|
16
|
+
export function toUserProps<T extends { username: string }>(
|
|
17
|
+
user: T,
|
|
18
|
+
extraProps: Partial<UserProps> = {},
|
|
19
|
+
): Omit<T, 'username'> & Partial<UserProps> {
|
|
20
|
+
const { username: _lookupKey, ...profile } = user
|
|
21
|
+
|
|
22
|
+
return { ...profile, ...extraProps }
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Fetches user details once and keeps the lookup key available for callers
|
|
27
|
+
* that need to associate a profile with several content entries.
|
|
28
|
+
*/
|
|
29
|
+
export async function resolveUserMap(users: string[], extraProps: Partial<UserProps> = {}) {
|
|
30
|
+
const uniqueUsers = [...new Set(users)]
|
|
31
|
+
|
|
32
|
+
if (uniqueUsers.length === 0)
|
|
33
|
+
return new Map<string, ResolvedUser>()
|
|
37
34
|
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
.
|
|
41
|
-
.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
35
|
+
const resolved = await queryCollection('user')
|
|
36
|
+
.where('username', 'IN', uniqueUsers)
|
|
37
|
+
.select('username', 'name', 'description', 'to', 'avatar')
|
|
38
|
+
.all()
|
|
39
|
+
|
|
40
|
+
return new Map(resolved.map(user => [user.username, toUserProps(user, extraProps)]))
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Fetches user details from the Nuxt Content user collection.
|
|
45
|
+
*
|
|
46
|
+
* The returned profiles follow the requested username order. Unknown users are omitted.
|
|
47
|
+
*
|
|
48
|
+
* @param users - A single username or an array of usernames
|
|
49
|
+
* @returns A promise resolving to the selected user profiles
|
|
50
|
+
*/
|
|
51
|
+
export default async function resolveUsers(users: string | string[], extraProps: Partial<UserProps> = {}) {
|
|
52
|
+
const userList = Array.isArray(users) ? users : [users]
|
|
53
|
+
const resolved = await resolveUserMap(userList, extraProps)
|
|
54
|
+
|
|
55
|
+
return userList.flatMap((username) => {
|
|
56
|
+
const user = resolved.get(username)
|
|
57
|
+
return user ? [user] : []
|
|
58
|
+
})
|
|
59
|
+
}
|
package/nuxt.config.ts
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
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
1
|
// https://nuxt.com/docs/api/configuration/nuxt-config
|
|
8
2
|
export default defineNuxtConfig({
|
|
9
3
|
|
|
@@ -15,10 +9,6 @@ export default defineNuxtConfig({
|
|
|
15
9
|
{ path: './components', pathPrefix: false, prefix: 'H' },
|
|
16
10
|
],
|
|
17
11
|
|
|
18
|
-
css: [
|
|
19
|
-
resolve(currentDir, './app/assets/css/main.css'),
|
|
20
|
-
],
|
|
21
|
-
|
|
22
12
|
devtools: { enabled: true },
|
|
23
13
|
|
|
24
14
|
modules: [
|
|
@@ -34,7 +24,7 @@ export default defineNuxtConfig({
|
|
|
34
24
|
dates: {},
|
|
35
25
|
authors: {},
|
|
36
26
|
category: {},
|
|
37
|
-
|
|
27
|
+
published: {},
|
|
38
28
|
header: {},
|
|
39
29
|
toc: {},
|
|
40
30
|
links: {},
|
|
@@ -52,11 +42,11 @@ export default defineNuxtConfig({
|
|
|
52
42
|
// Collection variants — extends chains defined here for graph generation
|
|
53
43
|
snippet: {},
|
|
54
44
|
article: {
|
|
55
|
-
extends: ['dates', 'authors', 'category', '
|
|
45
|
+
extends: ['dates', 'authors', 'category', 'published', 'header', 'toc', 'surround', 'copyButton', 'separator', 'backButton'],
|
|
56
46
|
config: {},
|
|
57
47
|
},
|
|
58
48
|
event: {
|
|
59
|
-
extends: ['dates', 'location', 'category', 'links', '
|
|
49
|
+
extends: ['dates', 'location', 'category', 'links', 'published', 'header', 'toc', 'surround', 'copyButton', 'separator', 'backButton'],
|
|
60
50
|
config: {},
|
|
61
51
|
},
|
|
62
52
|
page: {
|
|
@@ -66,7 +56,5 @@ export default defineNuxtConfig({
|
|
|
66
56
|
},
|
|
67
57
|
},
|
|
68
58
|
|
|
69
|
-
studio:
|
|
70
|
-
dev: true,
|
|
71
|
-
},
|
|
59
|
+
studio: false,
|
|
72
60
|
})
|
package/package.json
CHANGED
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@happydesigns/ui",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.17.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"packageManager": "pnpm@11.11.0",
|
|
7
7
|
"author": "happydesigns",
|
|
8
8
|
"homepage": "https://github.com/happydesigns",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": "./nuxt.config.ts",
|
|
11
|
-
"./schemas": "./schemas/index.ts"
|
|
11
|
+
"./schemas": "./schemas/index.ts",
|
|
12
|
+
"./styles.css": "./app/assets/css/styles.css",
|
|
13
|
+
"./types": "./app/types/config.ts"
|
|
12
14
|
},
|
|
13
15
|
"main": "./nuxt.config.ts",
|
|
14
16
|
"files": [
|
|
15
17
|
"app",
|
|
16
18
|
"content.config.ts",
|
|
17
19
|
"nuxt.config.ts",
|
|
18
|
-
"schemas"
|
|
20
|
+
"schemas",
|
|
21
|
+
"server",
|
|
22
|
+
"shared"
|
|
19
23
|
],
|
|
20
24
|
"publishConfig": {
|
|
21
25
|
"access": "public"
|
|
@@ -27,6 +31,9 @@
|
|
|
27
31
|
"docs:build:server": "nuxt build docs",
|
|
28
32
|
"prepare": "nuxt prepare && nuxt prepare playground",
|
|
29
33
|
"build": "nuxt build playground",
|
|
34
|
+
"generate": "nuxt generate playground && node scripts/validate-playground-output.mjs",
|
|
35
|
+
"package:check": "node scripts/validate-package.mjs",
|
|
36
|
+
"consumer:check": "node scripts/validate-consumer.mjs",
|
|
30
37
|
"preview": "nuxt preview playground",
|
|
31
38
|
"lint": "eslint .",
|
|
32
39
|
"lint:fix": "eslint . --fix",
|
|
@@ -38,17 +45,19 @@
|
|
|
38
45
|
"release:alpha": "changelogen --release --versionSuffix alpha.0",
|
|
39
46
|
"release:beta": "changelogen --release --versionSuffix beta.0"
|
|
40
47
|
},
|
|
48
|
+
"peerDependencies": {
|
|
49
|
+
"tailwindcss": "^4.3.2"
|
|
50
|
+
},
|
|
41
51
|
"dependencies": {
|
|
42
52
|
"@happydesigns/nuxt-variants": "^0.0.6",
|
|
43
53
|
"@iconify-json/heroicons": "^1.2.3",
|
|
44
54
|
"@iconify-json/lucide": "^1.2.116",
|
|
45
55
|
"@iconify-json/simple-icons": "^1.2.89",
|
|
46
56
|
"@nuxt/content": "^3.15.0",
|
|
47
|
-
"@nuxt/ui": "^4.
|
|
57
|
+
"@nuxt/ui": "^4.10.0",
|
|
48
58
|
"@vueuse/core": "^14.3.0",
|
|
49
59
|
"better-sqlite3": "^12.11.1",
|
|
50
60
|
"nuxt-studio": "^1.7.0",
|
|
51
|
-
"pathe": "^2.0.3",
|
|
52
61
|
"zod": "^4.4.3"
|
|
53
62
|
},
|
|
54
63
|
"devDependencies": {
|
|
@@ -59,13 +68,12 @@
|
|
|
59
68
|
"cross-env": "^10.1.0",
|
|
60
69
|
"docus": "5.12.3",
|
|
61
70
|
"eslint": "^10.6.0",
|
|
62
|
-
"nuxt": "
|
|
71
|
+
"nuxt": "4.5.1",
|
|
63
72
|
"typescript": "^6.0.3",
|
|
64
73
|
"vitest": "^4.1.10",
|
|
65
|
-
"vue-tsc": "^3.3.7"
|
|
66
|
-
"zod-to-json-schema": "^3.25.2"
|
|
74
|
+
"vue-tsc": "^3.3.7"
|
|
67
75
|
},
|
|
68
76
|
"resolutions": {
|
|
69
77
|
"@happydesigns/ui": "workspace:*"
|
|
70
78
|
}
|
|
71
|
-
}
|
|
79
|
+
}
|
package/schemas/collections.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { mergeVariantSchemas } from '@happydesigns/nuxt-variants/schemas'
|
|
2
2
|
import { defineCollection } from '@nuxt/content'
|
|
3
|
+
import { articleCollectionIndexes, userCollectionIndexes } from './indexes'
|
|
3
4
|
import { variantSchemas } from './traits'
|
|
4
5
|
|
|
5
6
|
export const collections = {
|
|
@@ -18,6 +19,7 @@ export const collections = {
|
|
|
18
19
|
prefix: '/articles',
|
|
19
20
|
},
|
|
20
21
|
schema: mergeVariantSchemas(['article'], variantSchemas),
|
|
22
|
+
indexes: articleCollectionIndexes,
|
|
21
23
|
}),
|
|
22
24
|
|
|
23
25
|
event: defineCollection({
|
|
@@ -27,6 +29,7 @@ export const collections = {
|
|
|
27
29
|
prefix: '/events',
|
|
28
30
|
},
|
|
29
31
|
schema: mergeVariantSchemas(['event'], variantSchemas),
|
|
32
|
+
indexes: articleCollectionIndexes,
|
|
30
33
|
}),
|
|
31
34
|
|
|
32
35
|
page: defineCollection({
|
|
@@ -42,5 +45,6 @@ export const collections = {
|
|
|
42
45
|
type: 'data',
|
|
43
46
|
source: 'users/**/*.{md,yaml}',
|
|
44
47
|
schema: mergeVariantSchemas(['user'], variantSchemas),
|
|
48
|
+
indexes: userCollectionIndexes,
|
|
45
49
|
}),
|
|
46
50
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CollectionIndex } from '@nuxt/content'
|
|
2
|
+
|
|
3
|
+
export const articleCollectionIndexes = [
|
|
4
|
+
{ columns: ['published', 'date'] },
|
|
5
|
+
{ columns: ['published', 'category', 'date'] },
|
|
6
|
+
] satisfies CollectionIndex[]
|
|
7
|
+
|
|
8
|
+
export const userCollectionIndexes = [
|
|
9
|
+
{ columns: ['username'], unique: true },
|
|
10
|
+
] satisfies CollectionIndex[]
|
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,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { queryCollectionNavigation } from '@nuxt/content/server'
|
|
2
|
+
|
|
3
|
+
export default defineEventHandler(async (event) => {
|
|
4
|
+
setSearchCacheHeaders(event)
|
|
5
|
+
const entries = await Promise.all(getSearchCollections().map((config) => {
|
|
6
|
+
const query = queryCollectionNavigation(event, asPageCollection(config.name))
|
|
7
|
+
return applySearchCollectionConfig(query, config)
|
|
8
|
+
}))
|
|
9
|
+
|
|
10
|
+
return entries.flat()
|
|
11
|
+
})
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { queryCollectionSearchSections } from '@nuxt/content/server'
|
|
2
|
+
|
|
3
|
+
export default defineEventHandler(async (event) => {
|
|
4
|
+
setSearchCacheHeaders(event)
|
|
5
|
+
const entries = await Promise.all(getSearchCollections().map((config) => {
|
|
6
|
+
const query = queryCollectionSearchSections(event, asPageCollection(config.name))
|
|
7
|
+
return applySearchCollectionConfig(query, config)
|
|
8
|
+
}))
|
|
9
|
+
|
|
10
|
+
return entries.flat()
|
|
11
|
+
})
|