@happydesigns/ui 0.14.0 → 0.15.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 CHANGED
@@ -1,94 +1,53 @@
1
1
  # @happydesigns/ui
2
2
 
3
- A foundational **Nuxt Layer** providing a consistent UI and content structure for Nuxt applications. Built with Nuxt 4, Nuxt UI 4, and Nuxt Content 3.
3
+ Reusable Nuxt layer for happydesigns websites, docs sites, and product apps.
4
4
 
5
- ## Features
6
-
7
- - 🎨 **Nuxt UI v4 Integration**: Pre-configured with Tailwind and a set of reusable components.
8
- - 📝 **Nuxt Content v3 Ready**: Provides pre-defined collections for pages and snippets to jumpstart content-driven sites.
9
- - 🔌 **Extendable**: Designed as a Nuxt Layer that can be easily extended and customized by consuming projects.
10
- - 🧱 **Prefixed Components**: Layer components are automatically prefixed with `H` (e.g., `<HFooterButtons />`) to avoid naming collisions.
11
- - ✨ **Studio Ready**: Integrated with [Nuxt Studio](https://nuxt.studio/) for a seamless content editing experience.
5
+ The package provides shared Nuxt setup, Nuxt UI conventions, content collection schemas, public `H*` components, composables, variants, and app config conventions. Projects extend the layer and keep project-specific routes, content, branding, and deployment settings in the project that owns them.
12
6
 
13
7
  ## Installation
14
8
 
15
- Install the package in your Nuxt project:
16
-
17
9
  ```bash
18
10
  pnpm add @happydesigns/ui
19
11
  ```
20
12
 
21
- Add the layer to your `nuxt.config.ts`:
22
-
23
13
  ```ts
24
14
  export default defineNuxtConfig({
25
- extends: ['@happydesigns/ui']
15
+ extends: ['@happydesigns/ui'],
26
16
  })
27
17
  ```
28
18
 
29
- ## Configuration
19
+ Run Nuxt preparation after changing dependencies or layer configuration:
30
20
 
31
- This layer provides a type-safe configuration via `app.config.ts`. You can override these values in your project's own `app.config.ts`:
21
+ ```bash
22
+ pnpm exec nuxt prepare
23
+ ```
32
24
 
33
- ```ts
34
- export default defineAppConfig({
35
- app: {
36
- meta: {
37
- copyright: {
38
- copyrightYear: 2026,
39
- copyrightHolder: 'happydesigns',
40
- copyrightHomepage: 'https://happydesigns.de'
41
- },
42
- socials: [
43
- { icon: 'i-simple-icons-github', to: 'https://github.com/happydesigns', target: '_blank' }
44
- ]
45
- },
46
- links: {
47
- footer: [
48
- { label: 'Privacy Policy', to: '/privacy' },
49
- { label: 'Terms of Service', to: '/terms' }
50
- ]
51
- }
52
- }
53
- })
25
+ ## Development
26
+
27
+ ```bash
28
+ pnpm install
29
+ pnpm prepare
30
+ pnpm dev
31
+ pnpm build
54
32
  ```
55
33
 
56
- ## Content Configuration
34
+ `pnpm dev` starts the playground app. `pnpm build` builds the playground.
57
35
 
58
- By default, this layer provides a `content.config.ts` that defines two collections: `page` (sourced from `pages/`) and `snippet` (sourced from `snippets/`).
36
+ ## Product Docs
59
37
 
60
- You can use these as-is by following the default directory structure, or you can define your own `content.config.ts` in your main application to extend or completely override these collections:
38
+ The product docs live in `docs/` and are built with Docus.
61
39
 
62
- ```ts
63
- // your-app/content.config.ts
64
- import { pageCollectionConfig, snippetCollectionConfig } from '@happydesigns/ui/content.config'
65
- import { defineContentConfig } from '@nuxt/content'
66
-
67
- export default defineContentConfig({
68
- collections: {
69
- // Reuse the layer's configs
70
- page: pageCollectionConfig,
71
- snippet: snippetCollectionConfig,
72
- // Or add your own
73
- posts: defineCollection({ })
74
- }
75
- })
40
+ ```bash
41
+ pnpm docs
42
+ pnpm docs:build
76
43
  ```
77
44
 
78
- ## Development
79
-
80
- If you want to contribute to the layer or run it locally:
45
+ `pnpm docs:build` generates a static Docus build in `docs/.output/public`. Use `pnpm docs:build:server` only when the deployment target needs a server-capable Docus build for live MCP support.
81
46
 
82
- ```bash
83
- # Install dependencies
84
- pnpm install
47
+ The docs explain how to use the layer, content model, components, composables, variants, and configuration. Component props, slots, examples, variants, and collection tables are generated from the package source where possible.
85
48
 
86
- # Prepare types
87
- pnpm prepare
49
+ ## Package Scope
88
50
 
89
- # Start the playground (dev server)
90
- pnpm dev
51
+ This package owns reusable interface and content foundations. It does not own project copy, customer-specific routes, final brand assets, deployment settings, or product-specific domain behavior.
91
52
 
92
- # Build the playground
93
- pnpm build
94
- ```
53
+ Use the product docs for usage guidance. Use the source files for implementation facts.
package/app/app.vue CHANGED
@@ -1,11 +1,11 @@
1
- <template>
2
- <UApp>
3
- <AppHeader />
4
- <UMain>
5
- <NuxtLayout>
6
- <NuxtPage />
7
- </NuxtLayout>
8
- </UMain>
9
- <AppFooter />
10
- </UApp>
11
- </template>
1
+ <template>
2
+ <UApp>
3
+ <AppHeader />
4
+ <UMain>
5
+ <NuxtLayout>
6
+ <NuxtPage />
7
+ </NuxtLayout>
8
+ </UMain>
9
+ <AppFooter />
10
+ </UApp>
11
+ </template>
@@ -1,6 +1,6 @@
1
1
  <script setup lang="ts" generic="C extends keyof PageCollections = 'article'">
2
2
  import type { PageCollections } from '@nuxt/content'
3
- import type { ArticleFilter } from '~/composables/useArticleList'
3
+ import type { ArticleFilter } from '../../composables/useArticleList'
4
4
 
5
5
  const props = withDefaults(defineProps<{
6
6
  /** Optional fixed category to filter by */
@@ -35,21 +35,21 @@ const { page, selectedCategory, updateQuery } = useArticleListQuery({
35
35
  fixedCategory: computed(() => props.category),
36
36
  })
37
37
 
38
- const { data, status: fetchStatus } = await useArticleList({
38
+ const { data, status: fetchStatus } = await useArticleList({
39
39
  page,
40
40
  itemsPerPage,
41
41
  category: selectedCategory,
42
42
  labelAll,
43
43
  collection: () => props.collection || 'article' as C,
44
- where: () => props.where,
45
- sort: () => props.sort,
46
- status: () => props.status,
47
- })
48
-
49
- const hasArticles = computed(() => Boolean(data.value?.articles.length))
50
- const isInitialLoading = computed(() => {
51
- return !hasArticles.value && (fetchStatus.value === 'idle' || fetchStatus.value === 'pending')
52
- })
44
+ where: () => props.where,
45
+ sort: () => props.sort,
46
+ status: () => props.status,
47
+ })
48
+
49
+ const hasArticles = computed(() => Boolean(data.value?.articles.length))
50
+ const isInitialLoading = computed(() => {
51
+ return !hasArticles.value && (fetchStatus.value === 'idle' || fetchStatus.value === 'pending')
52
+ })
53
53
 
54
54
  watch(page, () => {
55
55
  updateQuery()
@@ -80,16 +80,16 @@ watch(fetchStatus, (newStatus) => {
80
80
 
81
81
  <template>
82
82
  <div class="all:flex flex-col gap-8">
83
- <div v-if="isInitialLoading" class="all:flex justify-center py-20">
84
- <UIcon
85
- v-if="showLoader || fetchStatus === 'idle'"
86
- name="i-lucide-loader-circle"
87
- class="size-12 animate-spin text-muted"
88
- />
89
- </div>
83
+ <div v-if="isInitialLoading" class="all:flex justify-center py-20">
84
+ <UIcon
85
+ v-if="showLoader || fetchStatus === 'idle'"
86
+ name="i-lucide-loader-circle"
87
+ class="size-12 animate-spin text-muted"
88
+ />
89
+ </div>
90
90
 
91
91
  <UBlogPosts
92
- v-else-if="hasArticles"
92
+ v-else-if="hasArticles"
93
93
  :orientation="orientation || 'horizontal'"
94
94
  :ui="{
95
95
  base: (orientation || 'horizontal') === 'horizontal' ? 'sm:grid sm:grid-cols-2 lg:grid-cols-3' : '',
@@ -1,5 +1,5 @@
1
1
  <script setup lang="ts">
2
- import formatDate from '~/utils/formatDate'
2
+ import formatDate from '../../utils/formatDate'
3
3
 
4
4
  defineProps<{
5
5
  article: any
@@ -1,7 +1,7 @@
1
1
  <script setup lang="ts" generic="C extends keyof PageCollections = 'article'">
2
2
  import type { PageCollections } from '@nuxt/content'
3
- import type { ArticleFilter } from '~/composables/useArticleList'
4
- import { useArticleListQuery } from '~/composables/useArticleListQuery'
3
+ import type { ArticleFilter } from '../../composables/useArticleList'
4
+ import { useArticleListQuery } from '../../composables/useArticleListQuery'
5
5
 
6
6
  const props = withDefaults(defineProps<{
7
7
  /** Optional fixed category to filter by */
@@ -34,7 +34,7 @@ const { selectedCategory, updateQuery } = useArticleListQuery({
34
34
  })
35
35
 
36
36
  const categories = computed(() => {
37
- const cats = collectionConfig.value.categories || {}
37
+ const cats = (collectionConfig.value.categories || {}) as Record<string, { label?: string }>
38
38
  const items = [
39
39
  { label: String(labelAll.value), value: String(labelAll.value) },
40
40
  ...Object.keys(cats).map(key => ({
@@ -12,6 +12,6 @@ const { data: page } = await usePageContent({
12
12
  })
13
13
  </script>
14
14
 
15
- <template>
16
- <ContentRenderer v-if="page" :value="page" />
17
- </template>
15
+ <template>
16
+ <ContentRenderer v-if="page" :value="page" />
17
+ </template>
@@ -1,7 +1,6 @@
1
1
  <script setup lang="ts" generic="T extends FooterColumnLink">
2
- import type { FooterColumn, FooterColumnLink, FooterColumnsProps, FooterColumnsSlots } from '@nuxt/ui'
2
+ import type { FooterColumn, FooterColumnLink, FooterColumnsProps, FooterColumnsSlots, SlotClass } from '@nuxt/ui'
3
3
  import { useAppConfig } from '#imports'
4
- import { tv } from 'tailwind-variants'
5
4
 
6
5
  interface HFooterColumnProps<T extends FooterColumnLink> extends /* @vue-ignore */ FooterColumnsProps<T> {
7
6
  lgCols?: number
@@ -23,28 +22,25 @@ const rightCount = slots.right ? slots.right({}).length : 0
23
22
  const lgCount = Math.max(leftCount, centerCount, rightCount)
24
23
  const totalCount = leftCount + centerCount + rightCount
25
24
 
26
- const ui = tv({
27
- extend: tv({
28
- extend: tv({ slots: {
29
- root: 'footer-cols-root all:grid grid-flow-row gap-y-12 gap-x-8',
30
- left: 'footer-cols-left',
31
- center: 'footer-cols-center',
32
- right: 'footer-cols-right',
33
- } }),
34
- slots: appConfig.ui?.footerColumns?.slots || {},
35
- }),
36
- slots: props.ui || {},
37
- })()
25
+ function withLayoutClass(base: string, override?: SlotClass): SlotClass {
26
+ if (typeof override === 'function')
27
+ return defaults => [base, override(defaults)]
28
+
29
+ return [base, override]
30
+ }
31
+
32
+ const ui = computed(() => ({
33
+ ...props.ui,
34
+ root: withLayoutClass('footer-cols-root all:grid grid-flow-row gap-y-12 gap-x-8', props.ui?.root),
35
+ left: withLayoutClass('footer-cols-left', props.ui?.left),
36
+ center: withLayoutClass('footer-cols-center', props.ui?.center),
37
+ right: withLayoutClass('footer-cols-right', props.ui?.right),
38
+ }))
38
39
  </script>
39
40
 
40
41
  <template>
41
42
  <UFooterColumns
42
- v-bind="props" :columns="footerColumns" :ui="{
43
- root: ui.root?.() ?? '',
44
- left: ui.left?.() ?? '',
45
- center: ui.center?.() ?? '',
46
- right: ui.right?.() ?? '',
47
- }"
43
+ v-bind="props" :columns="footerColumns" :ui="ui"
48
44
  :style="{
49
45
  '--cols-sm': 1,
50
46
  '--cols-lg': props.lgCols ?? lgCount,
@@ -5,11 +5,17 @@ const props = defineProps<{
5
5
  copyrightHomepage?: string
6
6
  }>()
7
7
 
8
+ interface CopyrightConfig {
9
+ copyrightHolder?: string
10
+ copyrightHomepage?: string
11
+ }
12
+
8
13
  const appConfig = useAppConfig()
14
+ const copyright = appConfig.app?.meta?.copyright as CopyrightConfig | undefined
9
15
 
10
16
  const copyrightYear = props.copyrightYear ?? new Date().getFullYear()
11
- const copyrightHolder = props.copyrightHolder ?? appConfig.app?.meta?.copyright?.copyrightHolder ?? ''
12
- const copyrightHomepage = props.copyrightHomepage ?? appConfig.app?.meta?.copyright?.copyrightHomepage ?? ''
17
+ const copyrightHolder = props.copyrightHolder ?? copyright?.copyrightHolder ?? ''
18
+ const copyrightHomepage = props.copyrightHomepage ?? copyright?.copyrightHomepage ?? ''
13
19
  </script>
14
20
 
15
21
  <template>
@@ -1,8 +1,10 @@
1
1
  <script setup lang="ts">
2
+ import type { UserProps } from '@nuxt/ui'
3
+
2
4
  const props = defineProps<{
3
5
  authors?: string[]
4
6
  target?: string
5
- config?: VariantConfigOf<'user'>
7
+ config?: { user?: Partial<UserProps> }
6
8
  }>()
7
9
 
8
10
  const userProps = computed(() => ({ ...(props.config?.user ?? {}), ...(props.target ? { target: props.target } : {}) }))
@@ -1,5 +1,5 @@
1
1
  <script setup lang="ts">
2
- import formatDate from '~/utils/formatDate'
2
+ import formatDate from '../../utils/formatDate'
3
3
 
4
4
  defineProps<{
5
5
  date?: string
@@ -1,5 +1,5 @@
1
1
  <script setup lang="ts">
2
- import type { ActionButton } from '~/types/config'
2
+ import type { ActionButton } from '../../types/config'
3
3
 
4
4
  const props = defineProps<{
5
5
  stem?: string
@@ -1,5 +1,5 @@
1
1
  <script setup lang="ts">
2
- import type { ActionButton } from '~/types/config'
2
+ import type { ActionButton } from '../../types/config'
3
3
 
4
4
  const props = withDefaults(defineProps<{
5
5
  stem?: string
@@ -28,12 +28,13 @@ const reportLink = computed(() => {
28
28
 
29
29
  const buttons = computed(() =>
30
30
  props.buttons.flatMap((btn) => {
31
- let to = btn.to
32
- if (btn.type === 'github-edit')
31
+ const { action, ...buttonProps } = btn
32
+ let to = buttonProps.to
33
+ if (action === 'github-edit')
33
34
  to = editLink.value ?? undefined
34
- else if (btn.type === 'report-github-issue')
35
+ else if (action === 'report-github-issue')
35
36
  to = reportLink.value ?? undefined
36
- return to ? [{ ...btn, to }] : []
37
+ return to ? [{ ...buttonProps, to }] : []
37
38
  }),
38
39
  )
39
40
  </script>
@@ -1,6 +1,6 @@
1
1
  <script setup lang="ts" generic="C extends keyof PageCollections ">
2
2
  import type { PageCollections } from '@nuxt/content'
3
- import type { QueryConfig } from '~/types/config'
3
+ import type { QueryConfig } from '../../types/config'
4
4
 
5
5
  const props = defineProps<{
6
6
  collection: C
@@ -11,18 +11,21 @@ const props = defineProps<{
11
11
  }>()
12
12
 
13
13
  const route = useRoute()
14
+ const collection = computed(() => props.collection || 'article')
15
+ const path = computed(() => route.path)
16
+ const key = computed(() => `surround-${String(collection.value)}-${path.value}`)
14
17
 
15
18
  const { data: surround } = await useAsyncData(
16
- `surround-${String(props.collection || 'article')}-${route.path}`,
19
+ key,
17
20
  () => {
18
- const colName = (props.collection || 'article') as any
21
+ const colName = collection.value as any
19
22
  const qc = props.query || {}
20
23
 
21
24
  const fields = (qc.fields || ['title', 'description', 'status']) as any
22
25
  const order = qc.order
23
26
  const where = qc.where || [{ field: 'status', operator: '=', value: 'published' }]
24
27
 
25
- let query = queryCollectionItemSurroundings(colName, route.path, { fields })
28
+ let query = queryCollectionItemSurroundings(colName, path.value, { fields })
26
29
 
27
30
  where.forEach((filter) => {
28
31
  query = query.where(filter.field as any, filter.operator as any, filter.value)
@@ -20,11 +20,11 @@ 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
- /** Status to filter by. Set to false to disable default status filtering. Defaults to 'published'. */
24
- status?: MaybeRefOrGetter<string | false | undefined>
25
- /** Whether the list should load lazily during client-side navigation. Defaults to false. */
26
- lazy?: MaybeRefOrGetter<boolean | undefined>
27
- }
23
+ /** Status to filter by. Set to false to disable default status filtering. Defaults to 'published'. */
24
+ status?: MaybeRefOrGetter<string | false | undefined>
25
+ /** Whether the list should load lazily during client-side navigation. Defaults to false. */
26
+ lazy?: MaybeRefOrGetter<boolean | undefined>
27
+ }
28
28
 
29
29
  /**
30
30
  * Composable to fetch a paginated and filtered list of articles or any other collection.
@@ -73,7 +73,7 @@ export function useArticleList<C extends keyof PageCollections = 'article'>(opti
73
73
  // The key must be reactive and stable
74
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)}-${status.value}`)
75
75
 
76
- return useAsyncData(queryKey, async () => {
76
+ return useAsyncData(queryKey, async () => {
77
77
  // We cast the query to a version that includes the standard article fields
78
78
  // This avoids 'any' while still allowing the query to work with generic collections
79
79
  type ArticleItem = Collections[C] & Collections['article']
@@ -140,15 +140,15 @@ export function useArticleList<C extends keyof PageCollections = 'article'>(opti
140
140
  // Total count for pagination
141
141
  const total = await getDataQuery().count() as number
142
142
 
143
- return {
144
- articles: resolved,
145
- total,
146
- }
147
- }, {
148
- lazy: toValue(options.lazy) ?? false,
149
- default: () => ({
150
- articles: [],
151
- total: 0,
152
- }),
153
- })
154
- }
143
+ return {
144
+ articles: resolved,
145
+ total,
146
+ }
147
+ }, {
148
+ lazy: toValue(options.lazy) ?? false,
149
+ default: () => ({
150
+ articles: [],
151
+ total: 0,
152
+ }),
153
+ })
154
+ }
@@ -54,67 +54,67 @@ const backLink = computed(() => {
54
54
  })
55
55
  </script>
56
56
 
57
- <template>
58
- <UContainer v-if="page">
59
- <UPageHeader
60
- v-if="hasHeader && header"
61
- v-bind="header"
62
- :ui="{
63
- headline: 'all:flex flex-col gap-y-8 items-start',
64
- wrapper: 'lg:flex-row',
65
- }"
66
- >
67
- <template #headline>
68
- <UBreadcrumb
69
- :ui="{ root: 'max-w-full' }"
70
- :items="breadcrumbItems"
71
- />
72
- <HArticleHeadlineMeta :page="page" :collection="collection" />
73
- </template>
74
- <HArticleHeaderBody :page="page" :collection="collection">
75
- <slot name="header" />
76
- </HArticleHeaderBody>
77
- </UPageHeader>
78
-
79
- <UPage>
80
- <UPageBody>
81
- <slot />
82
-
83
- <div
84
- v-if="hasBackButton || hasCopyButton"
85
- class="all:flex items-center justify-between mt-12"
86
- >
87
- <HBackButton
88
- v-if="hasBackButton && backLink"
89
- v-bind="backLink"
90
- />
91
- <div class="all:flex justify-end items-center gap-1.5 ml-auto">
92
- <HCopyButton v-if="hasCopyButton" v-bind="config.copyButton" />
93
- </div>
94
- </div>
95
-
96
- <HSeparator
97
- v-if="hasSeparator"
98
- :stem="page?.stem"
99
- :extension="page?.extension"
100
- v-bind="config.separator"
101
- />
102
-
103
- <HSurround
104
- v-if="hasSurround"
105
- :collection="collection"
106
- v-bind="config.surround"
107
- :query="config.query"
108
- />
109
- </UPageBody>
110
-
111
- <template #right>
112
- <HToc
113
- v-if="hasToc && tocEnabled"
114
- :links="page?.body?.toc?.links"
115
- :title="page?.body?.toc?.title"
116
- />
117
- </template>
118
- </UPage>
119
- </UContainer>
120
- </template>
57
+ <template>
58
+ <UContainer v-if="page">
59
+ <UPageHeader
60
+ v-if="hasHeader && header"
61
+ v-bind="header"
62
+ :ui="{
63
+ headline: 'all:flex flex-col gap-y-8 items-start',
64
+ wrapper: 'lg:flex-row',
65
+ }"
66
+ >
67
+ <template #headline>
68
+ <UBreadcrumb
69
+ :ui="{ root: 'max-w-full' }"
70
+ :items="breadcrumbItems"
71
+ />
72
+ <HArticleHeadlineMeta :page="page" :collection="collection" />
73
+ </template>
74
+ <HArticleHeaderBody :page="page" :collection="collection">
75
+ <slot name="header" />
76
+ </HArticleHeaderBody>
77
+ </UPageHeader>
78
+
79
+ <UPage>
80
+ <UPageBody>
81
+ <slot />
82
+
83
+ <div
84
+ v-if="hasBackButton || hasCopyButton"
85
+ class="all:flex items-center justify-between mt-12"
86
+ >
87
+ <HBackButton
88
+ v-if="hasBackButton && backLink"
89
+ v-bind="backLink"
90
+ />
91
+ <div class="all:flex justify-end items-center gap-1.5 ml-auto">
92
+ <HCopyButton v-if="hasCopyButton" v-bind="config.copyButton" />
93
+ </div>
94
+ </div>
95
+
96
+ <HSeparator
97
+ v-if="hasSeparator"
98
+ :stem="page?.stem"
99
+ :extension="page?.extension"
100
+ v-bind="config.separator"
101
+ />
102
+
103
+ <HSurround
104
+ v-if="hasSurround"
105
+ :collection="collection"
106
+ v-bind="config.surround"
107
+ :query="config.query"
108
+ />
109
+ </UPageBody>
110
+
111
+ <template #right>
112
+ <HToc
113
+ v-if="hasToc && tocEnabled"
114
+ :links="page?.body?.toc?.links"
115
+ :title="page?.body?.toc?.title"
116
+ />
117
+ </template>
118
+ </UPage>
119
+ </UContainer>
120
+ </template>
@@ -35,25 +35,25 @@ const renderToc = computed(() => hasToc.value && page.value?.toc !== false)
35
35
  const header = computed(() => resolvePageHeader(page.value))
36
36
  </script>
37
37
 
38
- <template>
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>
59
- </template>
38
+ <template>
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>
59
+ </template>
@@ -1,3 +1,3 @@
1
- <template>
2
- <slot />
3
- </template>
1
+ <template>
2
+ <slot />
3
+ </template>
@@ -3,7 +3,7 @@ import type { ButtonProps } from '@nuxt/ui'
3
3
 
4
4
  export type ActionButton = ButtonProps & {
5
5
  /** Built-in type for a dynamic GitHub link (URL resolved from app.meta.github) */
6
- type?: 'github-edit' | 'report-github-issue'
6
+ action?: 'github-edit' | 'report-github-issue'
7
7
  }
8
8
 
9
9
  export interface QueryConfig {
@@ -1,16 +1,45 @@
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 }
27
+ }
28
+
1
29
  /**
2
30
  * Fetches user details from the Nuxt Content user collection.
3
31
  *
4
32
  * @param users - A single username or an array of usernames
5
33
  * @returns A promise resolving to the selected user profiles
6
34
  */
7
- export default async function resolveUsers(users: string | string[], extraProps: Record<string, any> = {}) {
35
+ export default async function resolveUsers(users: string | string[], extraProps: Partial<UserProps> = {}) {
8
36
  const userList = Array.isArray(users) ? users : [users]
9
37
 
10
- const resolved = await queryCollection('user')
38
+ const queryUserCollection = queryCollection as unknown as (collection: 'user') => UserQuery
39
+ const resolved = await queryUserCollection('user')
11
40
  .where('username', 'IN', userList)
12
41
  .select('username', 'name', 'description', 'to', 'avatar')
13
42
  .all()
14
43
 
15
- return resolved.map(user => ({ ...user, ...extraProps }))
44
+ return resolved.map(user => toUserProps(user, extraProps))
16
45
  }
package/nuxt.config.ts CHANGED
@@ -22,7 +22,6 @@ export default defineNuxtConfig({
22
22
  devtools: { enabled: true },
23
23
 
24
24
  modules: [
25
- '@nuxt/eslint',
26
25
  '@happydesigns/nuxt-variants',
27
26
  '@nuxt/ui',
28
27
  '@nuxt/content',
@@ -67,13 +66,6 @@ export default defineNuxtConfig({
67
66
  },
68
67
  },
69
68
 
70
- eslint: {
71
- config: {
72
- stylistic: true,
73
- standalone: false,
74
- },
75
- },
76
-
77
69
  studio: {
78
70
  dev: true,
79
71
  },
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@happydesigns/ui",
3
3
  "type": "module",
4
- "version": "0.14.0",
4
+ "version": "0.15.0",
5
5
  "private": false,
6
- "packageManager": "pnpm@10.33.0",
6
+ "packageManager": "pnpm@11.11.0",
7
7
  "author": "happydesigns",
8
8
  "homepage": "https://github.com/happydesigns",
9
9
  "exports": {
@@ -22,12 +22,17 @@
22
22
  },
23
23
  "scripts": {
24
24
  "dev": "nuxt dev playground",
25
- "docs": "nuxt dev docs --extends docus",
25
+ "docs": "nuxt dev docs",
26
+ "docs:build": "nuxt generate docs && node scripts/validate-docs-output.mjs",
27
+ "docs:build:server": "nuxt build docs",
26
28
  "prepare": "nuxt prepare && nuxt prepare playground",
27
29
  "build": "nuxt build playground",
28
30
  "preview": "nuxt preview playground",
29
31
  "lint": "eslint .",
30
32
  "lint:fix": "eslint . --fix",
33
+ "typecheck": "nuxt typecheck && nuxt typecheck playground",
34
+ "test": "vitest run",
35
+ "test:watch": "vitest",
31
36
  "release": "changelogen --release",
32
37
  "release:pre": "changelogen --release --prerelease",
33
38
  "release:alpha": "changelogen --release --versionSuffix alpha.0",
@@ -36,23 +41,29 @@
36
41
  "dependencies": {
37
42
  "@happydesigns/nuxt-variants": "^0.0.6",
38
43
  "@iconify-json/heroicons": "^1.2.3",
39
- "@iconify-json/lucide": "^1.2.101",
40
- "@iconify-json/simple-icons": "^1.2.76",
41
- "@nuxt/content": "^3.12.0",
42
- "@nuxt/ui": "^4.6.1",
43
- "better-sqlite3": "^12.8.0",
44
- "nuxt-studio": "^1.5.1"
44
+ "@iconify-json/lucide": "^1.2.116",
45
+ "@iconify-json/simple-icons": "^1.2.89",
46
+ "@nuxt/content": "^3.15.0",
47
+ "@nuxt/ui": "^4.9.0",
48
+ "@vueuse/core": "^14.3.0",
49
+ "better-sqlite3": "^12.11.1",
50
+ "nuxt-studio": "^1.7.0",
51
+ "pathe": "^2.0.3",
52
+ "zod": "^4.4.3"
45
53
  },
46
54
  "devDependencies": {
47
- "@antfu/eslint-config": "^8.0.0",
48
- "@antfu/ni": "^30.0.0",
49
- "@nuxt/eslint": "^1.15.2",
55
+ "@antfu/eslint-config": "^9.1.0",
56
+ "@antfu/ni": "^30.2.0",
57
+ "@nuxt/eslint-config": "^1.16.0",
50
58
  "changelogen": "^0.6.2",
51
59
  "cross-env": "^10.1.0",
52
- "eslint": "^10.2.0",
53
- "nuxt": "^4.4.2",
54
- "typescript": "^6.0.2",
55
- "zod": "^4.3.6"
60
+ "docus": "5.12.3",
61
+ "eslint": "^10.6.0",
62
+ "nuxt": "^4.4.8",
63
+ "typescript": "^6.0.3",
64
+ "vitest": "^4.1.10",
65
+ "vue-tsc": "^3.3.7",
66
+ "zod-to-json-schema": "^3.25.2"
56
67
  },
57
68
  "resolutions": {
58
69
  "@happydesigns/ui": "workspace:*"