@happydesigns/ui 0.19.2 → 0.20.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.
Files changed (30) hide show
  1. package/README.md +17 -0
  2. package/app/app.config.ts +81 -86
  3. package/app/components/traits/Breadcrumbs.vue +40 -0
  4. package/{app → content/app}/components/ContentPage.vue +54 -54
  5. package/{app → content/app}/components/Snippet.vue +1 -1
  6. package/{app → content/app}/components/article/ArticleGrid.vue +1 -1
  7. package/{app → content/app}/components/article/ArticleGridDate.vue +19 -19
  8. package/{app → content/app}/components/article/ArticleHeaderBody.vue +1 -1
  9. package/{app → content/app}/components/article/ArticleHeadlineMeta.vue +1 -1
  10. package/{app → content/app}/components/article/ArticleList.vue +1 -1
  11. package/{app → content/app}/components/article/ArticlePage.vue +1 -1
  12. package/{app → content/app}/components/search/ContentSearch.client.vue +59 -59
  13. package/{app → content/app}/components/studio/StudioLoginButton.client.vue +78 -78
  14. package/{app → content/app}/components/traits/Surround.vue +2 -2
  15. package/{app → content/app}/composables/useArticleList.ts +1 -1
  16. package/{app → content/app}/composables/useContentSearchData.ts +42 -42
  17. package/{app → content/app}/composables/usePageContent.ts +1 -1
  18. package/{app → content/app}/layouts/article.vue +10 -22
  19. package/{app → content/app}/layouts/content.vue +21 -21
  20. package/{app → content/app}/utils/resolveUsers.ts +1 -1
  21. package/content/nuxt.config.ts +7 -0
  22. package/{server → content/server}/api/navigation.json.get.ts +11 -11
  23. package/{server → content/server}/api/search.json.get.ts +11 -11
  24. package/{server → content/server}/utils/contentSearch.ts +2 -2
  25. package/nuxt.config.ts +25 -28
  26. package/package.json +10 -4
  27. package/schemas/variants.ts +5 -3
  28. package/shared/types/app-config.d.ts +0 -10
  29. /package/{app → content/app}/components/traits/Authors.vue +0 -0
  30. /package/{app → content/app}/composables/useArticleListQuery.ts +0 -0
package/README.md CHANGED
@@ -41,6 +41,23 @@ pnpm exec nuxt prepare
41
41
 
42
42
  ## Content collections
43
43
 
44
+ Applications using Nuxt Content extend `@happydesigns/ui/content` instead of
45
+ `@happydesigns/ui`. This optional layer includes article/content layouts,
46
+ `HContentPage`, `HSnippet`, content search, author lookup, navigation endpoints,
47
+ and Nuxt Studio (disabled unless configured by the application).
48
+
49
+ ```ts
50
+ export default defineNuxtConfig({
51
+ extends: ['@happydesigns/ui/content'],
52
+ })
53
+ ```
54
+
55
+ **Migration from 0.19.x:** change the layer entry point above if your application
56
+ uses these features. The base entry point now registers only Nuxt UI and variants;
57
+ Comark applications can keep it without initializing Nuxt Content or Studio.
58
+ The dependencies remain installed for the optional layer, but are not activated
59
+ by the base layer.
60
+
44
61
  The layer exports reusable schema profiles, but it does not register collection names, sources, or route prefixes for an application. Define those locally in the consumer's `content.config.ts`:
45
62
 
46
63
  ```ts
package/app/app.config.ts CHANGED
@@ -1,84 +1,80 @@
1
- import type { AppConfigInput as NuxtUiConfigInput } from '@nuxt/schema'
2
- import type { BadgeProps, ButtonProps } from '@nuxt/ui'
3
- import type { AppConfigInput as LayerAppConfigInput } from 'nuxt/schema'
4
- import type { QueryConfig, SearchConfig } from './types/config'
5
-
6
- export * from './types/config'
7
-
8
- const ui = {
9
- main: {
10
- base: 'wrap-break-word',
11
- },
12
- } satisfies NonNullable<NuxtUiConfigInput['ui']>
13
-
14
- export default defineAppConfig({
15
- variants: {
16
- // UI feature variants — config overrides (extends defined in nuxt.config.ts)
17
- user: { config: { user: { target: '_blank' } } },
18
- backButton: { config: { backButton: { icon: 'i-ph-arrow-left', label: 'Back' } as Pick<ButtonProps, 'icon' | 'label' | 'to'> } },
19
- copyButton: {
20
- config: {
21
- copyButton: {
22
- icon: 'i-ph-link-simple-duotone',
23
- label: 'Copy URL',
24
- successIcon: 'i-lucide-copy-check',
25
- successLabel: 'Link copied to clipboard',
26
- errorIcon: 'i-lucide-copy-x',
27
- errorLabel: 'Link could not be copied',
28
- },
29
- },
30
- },
31
- separator: { config: { separator: { buttons: [], separator: 'or' } } },
32
- surround: {
33
- config: {
34
- surround: {
35
- show: true,
36
- prevIcon: 'i-lucide-arrow-left',
37
- nextIcon: 'i-lucide-arrow-right',
38
- prevLabel: 'Previous',
39
- nextLabel: 'Next',
40
- },
41
- },
42
- },
43
-
44
- // Collection variants — runtime config overrides only
45
- article: {
46
- config: {
47
- query: {
48
- fields: ['title', 'description', 'published', 'date'],
49
- order: { field: 'date', direction: 'DESC' },
50
- where: [{ field: 'published', operator: '=', value: true }],
51
- } as QueryConfig,
52
- categories: {} as Record<string, BadgeProps>,
53
- breadcrumbs: [],
54
- list: {
55
- itemsPerPage: 12,
56
- labelAll: 'All',
57
- noResultsMessage: 'No articles found.',
58
- noResultsIcon: 'i-ph-article-ny-times-light',
59
- },
60
- },
61
- },
62
- event: {
63
- config: {
64
- query: {
65
- fields: ['title', 'description', 'published', 'date', 'dateEnd', 'location'],
66
- order: { field: 'date', direction: 'DESC' },
67
- where: [{ field: 'published', operator: '=', value: true }],
68
- } as QueryConfig,
69
- categories: {} as Record<string, BadgeProps>,
70
- breadcrumbs: [],
71
- list: {
72
- itemsPerPage: 12,
73
- labelAll: 'All',
74
- noResultsMessage: 'No events found.',
75
- noResultsIcon: 'i-ph-calendar-blank',
76
- },
77
- },
78
- },
79
- },
80
-
81
- app: {
1
+ import type { AppConfigInput } from '@nuxt/schema'
2
+ import type { BadgeProps, ButtonProps } from '@nuxt/ui'
3
+ import type { QueryConfig, SearchConfig } from './types/config'
4
+
5
+ export * from './types/config'
6
+
7
+ const ui = {
8
+ main: {
9
+ base: 'wrap-break-word',
10
+ },
11
+ } satisfies NonNullable<AppConfigInput['ui']>
12
+
13
+ export default defineAppConfig({
14
+ variants: {
15
+ user: { config: { user: { target: '_blank' } } },
16
+ backButton: { config: { backButton: { icon: 'i-ph-arrow-left', label: 'Back' } as Pick<ButtonProps, 'icon' | 'label' | 'to'> } },
17
+ copyButton: {
18
+ config: {
19
+ copyButton: {
20
+ icon: 'i-ph-link-simple-duotone',
21
+ label: 'Copy URL',
22
+ successIcon: 'i-lucide-copy-check',
23
+ successLabel: 'Link copied to clipboard',
24
+ errorIcon: 'i-lucide-copy-x',
25
+ errorLabel: 'Link could not be copied',
26
+ },
27
+ },
28
+ },
29
+ separator: { config: { separator: { buttons: [], separator: 'or' } } },
30
+ surround: {
31
+ config: {
32
+ surround: {
33
+ show: true,
34
+ prevIcon: 'i-lucide-arrow-left',
35
+ nextIcon: 'i-lucide-arrow-right',
36
+ prevLabel: 'Previous',
37
+ nextLabel: 'Next',
38
+ },
39
+ },
40
+ },
41
+ article: {
42
+ config: {
43
+ query: {
44
+ fields: ['title', 'description', 'published', 'date'],
45
+ order: { field: 'date', direction: 'DESC' },
46
+ where: [{ field: 'published', operator: '=', value: true }],
47
+ } as QueryConfig,
48
+ categories: {} as Record<string, BadgeProps>,
49
+ breadcrumbs: [],
50
+ list: {
51
+ itemsPerPage: 12,
52
+ labelAll: 'All',
53
+ noResultsMessage: 'No articles found.',
54
+ noResultsIcon: 'i-ph-article-ny-times-light',
55
+ },
56
+ },
57
+ },
58
+ event: {
59
+ config: {
60
+ query: {
61
+ fields: ['title', 'description', 'published', 'date', 'dateEnd', 'location'],
62
+ order: { field: 'date', direction: 'DESC' },
63
+ where: [{ field: 'published', operator: '=', value: true }],
64
+ } as QueryConfig,
65
+ categories: {} as Record<string, BadgeProps>,
66
+ breadcrumbs: [],
67
+ list: {
68
+ itemsPerPage: 12,
69
+ labelAll: 'All',
70
+ noResultsMessage: 'No events found.',
71
+ noResultsIcon: 'i-ph-calendar-blank',
72
+ },
73
+ },
74
+ },
75
+ },
76
+
77
+ app: {
82
78
  meta: {
83
79
  copyright: {},
84
80
  socials: [],
@@ -138,8 +134,7 @@ export default defineAppConfig({
138
134
  minute: 'numeric',
139
135
  } as Intl.DateTimeFormatOptions,
140
136
  },
141
- },
142
-
143
- // The object is validated above; this bridges Nuxt's generated runtime-complete layer type.
144
- ui: ui as unknown as LayerAppConfigInput['ui'],
145
- })
137
+ },
138
+
139
+ ui,
140
+ })
@@ -0,0 +1,40 @@
1
+ <script setup lang="ts">
2
+ import type { BreadcrumbItem } from '@nuxt/ui'
3
+
4
+ const props = withDefaults(defineProps<{
5
+ items?: BreadcrumbItem[]
6
+ current?: BreadcrumbItem
7
+ }>(), {
8
+ items: () => [],
9
+ })
10
+
11
+ const breadcrumbItems = computed(() => {
12
+ const baseItems = props.items.map((item, index) => ({
13
+ ...item,
14
+ ui: {
15
+ ...item.ui,
16
+ ...(index === 0 ? { item: 'shrink-0', link: 'shrink-0' } : {}),
17
+ ...(props.current && index === props.items.length - 1
18
+ ? { separator: 'hidden sm:flex' }
19
+ : {}),
20
+ },
21
+ }))
22
+
23
+ return props.current
24
+ ? [
25
+ ...baseItems,
26
+ {
27
+ ...props.current,
28
+ ui: { ...props.current.ui, item: 'hidden sm:flex' },
29
+ },
30
+ ]
31
+ : baseItems
32
+ })
33
+ </script>
34
+
35
+ <template>
36
+ <UBreadcrumb
37
+ :ui="{ root: 'max-w-full' }"
38
+ :items="breadcrumbItems"
39
+ />
40
+ </template>
@@ -1,54 +1,54 @@
1
- <script setup lang="ts" generic="C extends PageCollectionName = 'page'">
2
- import type { PageCollectionItemBase } from '@nuxt/content'
3
- import type { PageCollectionName } from '../types/content'
4
-
5
- defineOptions({ inheritAttrs: false })
6
-
7
- const {
8
- collection = 'page' as C,
9
- path,
10
- page: suppliedPage,
11
- } = defineProps<{
12
- /** Consumer-owned page collection. */
13
- collection?: C
14
- /** Route path override. The current route path is used by default. */
15
- path?: string
16
- /** Already resolved document, useful when a route needs project-specific side effects. */
17
- page?: PageCollectionItemBase | null
18
- }>()
19
-
20
- const fetched = suppliedPage === undefined
21
- ? await usePageContent<C>({
22
- collection: () => collection,
23
- path: () => path,
24
- })
25
- : undefined
26
-
27
- const page = computed(() => suppliedPage === undefined ? fetched?.data.value : suppliedPage)
28
-
29
- if (!page.value) {
30
- throw createError({
31
- statusCode: 404,
32
- statusMessage: `${collection} ${path || useRoute().path} not found`,
33
- fatal: true,
34
- })
35
- }
36
- </script>
37
-
38
- <template>
39
- <NuxtLayout
40
- v-if="page"
41
- name="content"
42
- :collection="collection"
43
- :path="path"
44
- :page="page"
45
- >
46
- <slot :page="page">
47
- <ContentRenderer
48
- :value="page"
49
- class="h-content"
50
- v-bind="$attrs"
51
- />
52
- </slot>
53
- </NuxtLayout>
54
- </template>
1
+ <script setup lang="ts" generic="C extends PageCollectionName = 'page'">
2
+ import type { PageCollectionItemBase } from '@nuxt/content'
3
+ import type { PageCollectionName } from '../../../app/types/content'
4
+
5
+ defineOptions({ inheritAttrs: false })
6
+
7
+ const {
8
+ collection = 'page' as C,
9
+ path,
10
+ page: suppliedPage,
11
+ } = defineProps<{
12
+ /** Consumer-owned page collection. */
13
+ collection?: C
14
+ /** Route path override. The current route path is used by default. */
15
+ path?: string
16
+ /** Already resolved document, useful when a route needs project-specific side effects. */
17
+ page?: PageCollectionItemBase | null
18
+ }>()
19
+
20
+ const fetched = suppliedPage === undefined
21
+ ? await usePageContent<C>({
22
+ collection: () => collection,
23
+ path: () => path,
24
+ })
25
+ : undefined
26
+
27
+ const page = computed(() => suppliedPage === undefined ? fetched?.data.value : suppliedPage)
28
+
29
+ if (!page.value) {
30
+ throw createError({
31
+ statusCode: 404,
32
+ statusMessage: `${collection} ${path || useRoute().path} not found`,
33
+ fatal: true,
34
+ })
35
+ }
36
+ </script>
37
+
38
+ <template>
39
+ <NuxtLayout
40
+ v-if="page"
41
+ name="content"
42
+ :collection="collection"
43
+ :path="path"
44
+ :page="page"
45
+ >
46
+ <slot :page="page">
47
+ <ContentRenderer
48
+ :value="page"
49
+ class="h-content"
50
+ v-bind="$attrs"
51
+ />
52
+ </slot>
53
+ </NuxtLayout>
54
+ </template>
@@ -1,7 +1,7 @@
1
1
  <script setup lang="ts">
2
2
  import type { PageCollections } from '@nuxt/content'
3
3
  import type { Component } from 'vue'
4
- import type { PageCollectionName } from '../types/content'
4
+ import type { PageCollectionName } from '../../../app/types/content'
5
5
 
6
6
  const props = withDefaults(defineProps<{
7
7
  path: string
@@ -1,6 +1,6 @@
1
1
  <script setup lang="ts" generic="C extends PageCollectionName = 'article'">
2
+ import type { PageCollectionName } from '../../../../app/types/content'
2
3
  import type { ArticleFilter } from '../../composables/useArticleList'
3
- import type { PageCollectionName } from '../../types/content'
4
4
 
5
5
  const props = withDefaults(defineProps<{
6
6
  /** Optional fixed category to filter by */
@@ -1,19 +1,19 @@
1
- <script setup lang="ts">
2
- import formatDate from '../../utils/formatDate'
3
-
4
- defineProps<{
5
- article: {
6
- date?: string
7
- dateEnd?: string
8
- }
9
- }>()
10
- </script>
11
-
12
- <template>
13
- <time v-if="article.date" class="text-xs text-muted">
14
- {{ formatDate(article.date) }}
15
- <template v-if="article.dateEnd && article.date !== article.dateEnd">
16
- - {{ formatDate(article.dateEnd) }}
17
- </template>
18
- </time>
19
- </template>
1
+ <script setup lang="ts">
2
+ import formatDate from '../../../../app/utils/formatDate'
3
+
4
+ defineProps<{
5
+ article: {
6
+ date?: string
7
+ dateEnd?: string
8
+ }
9
+ }>()
10
+ </script>
11
+
12
+ <template>
13
+ <time v-if="article.date" class="text-xs text-muted">
14
+ {{ formatDate(article.date) }}
15
+ <template v-if="article.dateEnd && article.date !== article.dateEnd">
16
+ - {{ formatDate(article.dateEnd) }}
17
+ </template>
18
+ </time>
19
+ </template>
@@ -1,5 +1,5 @@
1
1
  <script setup lang="ts">
2
- import type { ContentLink, PageCollectionName } from '../../types/content'
2
+ import type { ContentLink, PageCollectionName } from '../../../../app/types/content'
3
3
 
4
4
  interface HeaderBodyPage {
5
5
  path?: string
@@ -1,5 +1,5 @@
1
1
  <script setup lang="ts">
2
- import type { PageCollectionName } from '../../types/content'
2
+ import type { PageCollectionName } from '../../../../app/types/content'
3
3
 
4
4
  interface HeadlineMetaPage {
5
5
  path?: string
@@ -1,6 +1,6 @@
1
1
  <script setup lang="ts" generic="C extends PageCollectionName = 'article'">
2
+ import type { PageCollectionName } from '../../../../app/types/content'
2
3
  import type { ArticleFilter } from '../../composables/useArticleList'
3
- import type { PageCollectionName } from '../../types/content'
4
4
  import { useArticleListQuery } from '../../composables/useArticleListQuery'
5
5
 
6
6
  const props = withDefaults(defineProps<{
@@ -1,5 +1,5 @@
1
1
  <script setup lang="ts">
2
- import type { PageCollectionName } from '../../types/content'
2
+ import type { PageCollectionName } from '../../../../app/types/content'
3
3
 
4
4
  const { collection = 'article', path } = defineProps<{
5
5
  collection?: PageCollectionName
@@ -1,59 +1,59 @@
1
- <script setup lang="ts">
2
- import type { CommandPaletteGroup } from '@nuxt/ui'
3
-
4
- const appConfig = useAppConfig()
5
- const { open } = useContentSearch()
6
- const search = computed(() => appConfig.app.search)
7
- const searchTerm = ref('')
8
- const { navigation, files, status, error, load } = useContentSearchData()
9
-
10
- const groups = computed<CommandPaletteGroup[]>(() => {
11
- const configuredGroups = search.value.groups ?? []
12
-
13
- if (!error.value) {
14
- return configuredGroups
15
- }
16
-
17
- return [
18
- {
19
- id: 'search-error',
20
- label: search.value.error?.title,
21
- ignoreFilter: true,
22
- items: [
23
- {
24
- label: search.value.error?.retryLabel,
25
- description: search.value.error?.description,
26
- icon: 'i-lucide-refresh-cw',
27
- onSelect: () => void load(),
28
- },
29
- ],
30
- },
31
- ...configuredGroups,
32
- ]
33
- })
34
-
35
- watch(open, (isOpen) => {
36
- if (isOpen) {
37
- void load().then(() => {
38
- if (error.value) {
39
- console.error('Failed to load the search index.', error.value)
40
- }
41
- })
42
- }
43
- }, { immediate: true })
44
- </script>
45
-
46
- <template>
47
- <UContentSearch
48
- v-model:search-term="searchTerm"
49
- :title="search.title"
50
- :description="search.description"
51
- :placeholder="search.placeholder"
52
- :links="search.links"
53
- :groups="groups"
54
- :files="files"
55
- :navigation="navigation"
56
- :loading="status === 'pending'"
57
- :fuse="{ resultLimit: search.resultLimit }"
58
- />
59
- </template>
1
+ <script setup lang="ts">
2
+ import type { CommandPaletteGroup } from '@nuxt/ui'
3
+
4
+ const appConfig = useAppConfig()
5
+ const { open } = useContentSearch()
6
+ const search = computed(() => appConfig.app.search)
7
+ const searchTerm = ref('')
8
+ const { navigation, files, status, error, load } = useContentSearchData()
9
+
10
+ const groups = computed<CommandPaletteGroup[]>(() => {
11
+ const configuredGroups = search.value.groups ?? []
12
+
13
+ if (!error.value) {
14
+ return configuredGroups
15
+ }
16
+
17
+ return [
18
+ {
19
+ id: 'search-error',
20
+ label: search.value.error?.title,
21
+ ignoreFilter: true,
22
+ items: [
23
+ {
24
+ label: search.value.error?.retryLabel,
25
+ description: search.value.error?.description,
26
+ icon: 'i-lucide-refresh-cw',
27
+ onSelect: () => void load(),
28
+ },
29
+ ],
30
+ },
31
+ ...configuredGroups,
32
+ ]
33
+ })
34
+
35
+ watch(open, (isOpen) => {
36
+ if (isOpen) {
37
+ void load().then(() => {
38
+ if (error.value) {
39
+ console.error('Failed to load the search index.', error.value)
40
+ }
41
+ })
42
+ }
43
+ }, { immediate: true })
44
+ </script>
45
+
46
+ <template>
47
+ <UContentSearch
48
+ v-model:search-term="searchTerm"
49
+ :title="search.title"
50
+ :description="search.description"
51
+ :placeholder="search.placeholder"
52
+ :links="search.links"
53
+ :groups="groups"
54
+ :files="files"
55
+ :navigation="navigation"
56
+ :loading="status === 'pending'"
57
+ :fuse="{ resultLimit: search.resultLimit }"
58
+ />
59
+ </template>
@@ -1,18 +1,18 @@
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
-
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
16
  interface StudioSession {
17
17
  user?: StudioUser | null
18
18
  }
@@ -20,69 +20,69 @@ interface StudioSession {
20
20
  interface StudioRuntimeConfig {
21
21
  dev?: boolean
22
22
  route?: string
23
- }
24
-
25
- const runtimeConfig = useRuntimeConfig()
26
- const sessionCheckCookie = useCookie<string | null>('studio-session-check')
27
- const sessionUser = ref<StudioUser | null | undefined>()
28
-
23
+ }
24
+
25
+ const runtimeConfig = useRuntimeConfig()
26
+ const sessionCheckCookie = useCookie<string | null>('studio-session-check')
27
+ const sessionUser = ref<StudioUser | null | undefined>()
28
+
29
29
  const studio = computed<StudioRuntimeConfig>(() => {
30
30
  const config = runtimeConfig.public.studio
31
31
  return config && typeof config === 'object' ? config as StudioRuntimeConfig : {}
32
- })
33
- const studioRoute = computed(() => studio.value.route || '/_studio')
34
-
35
- onMounted(async () => {
36
- if (studio.value.dev) {
37
- return
38
- }
39
-
40
- if (String(sessionCheckCookie.value) !== 'true') {
41
- sessionUser.value = null
42
- return
43
- }
44
-
45
- try {
46
- const session = await $fetch('/__nuxt_studio/auth/session') as StudioSession
47
- sessionUser.value = session.user ?? null
48
- }
49
- catch {
50
- sessionUser.value = null
51
- }
52
-
53
- if (!sessionUser.value?.email) {
54
- sessionCheckCookie.value = null
55
- }
56
- })
57
-
58
- const isLoggedIn = computed(() => {
59
- if (studio.value.dev) {
60
- return true
61
- }
62
-
63
- if (String(sessionCheckCookie.value) !== 'true') {
64
- return false
65
- }
66
-
67
- if (sessionUser.value === undefined) {
68
- return true
69
- }
70
-
71
- return Boolean(sessionUser.value?.email)
72
- })
73
- </script>
74
-
75
- <template>
76
- <UButton
77
- v-if="!isLoggedIn"
78
- :to="studioRoute"
79
- external
80
- :aria-label="ariaLabel"
81
- :icon="icon"
82
- :label="label"
83
- color="neutral"
84
- variant="outline"
85
- size="sm"
86
- class="fixed bottom-2 left-2 z-50 print:hidden"
87
- />
88
- </template>
32
+ })
33
+ const studioRoute = computed(() => studio.value.route || '/_studio')
34
+
35
+ onMounted(async () => {
36
+ if (studio.value.dev) {
37
+ return
38
+ }
39
+
40
+ if (String(sessionCheckCookie.value) !== 'true') {
41
+ sessionUser.value = null
42
+ return
43
+ }
44
+
45
+ try {
46
+ const session = await $fetch('/__nuxt_studio/auth/session') as StudioSession
47
+ sessionUser.value = session.user ?? null
48
+ }
49
+ catch {
50
+ sessionUser.value = null
51
+ }
52
+
53
+ if (!sessionUser.value?.email) {
54
+ sessionCheckCookie.value = null
55
+ }
56
+ })
57
+
58
+ const isLoggedIn = computed(() => {
59
+ if (studio.value.dev) {
60
+ return true
61
+ }
62
+
63
+ if (String(sessionCheckCookie.value) !== 'true') {
64
+ return false
65
+ }
66
+
67
+ if (sessionUser.value === undefined) {
68
+ return true
69
+ }
70
+
71
+ return Boolean(sessionUser.value?.email)
72
+ })
73
+ </script>
74
+
75
+ <template>
76
+ <UButton
77
+ v-if="!isLoggedIn"
78
+ :to="studioRoute"
79
+ external
80
+ :aria-label="ariaLabel"
81
+ :icon="icon"
82
+ :label="label"
83
+ color="neutral"
84
+ variant="outline"
85
+ size="sm"
86
+ class="fixed bottom-2 left-2 z-50 print:hidden"
87
+ />
88
+ </template>
@@ -1,7 +1,7 @@
1
1
  <script setup lang="ts" generic="C extends PageCollectionName">
2
2
  import type { PageCollections } from '@nuxt/content'
3
- import type { QueryConfig } from '../../types/config'
4
- import type { PageCollectionName } from '../../types/content'
3
+ import type { QueryConfig } from '../../../../app/types/config'
4
+ import type { PageCollectionName } from '../../../../app/types/content'
5
5
 
6
6
  type PageField = Extract<keyof PageCollections[keyof PageCollections], string>
7
7
 
@@ -1,7 +1,7 @@
1
1
  import type { CollectionQueryBuilder, Collections, PageCollectionItemBase, PageCollections, SQLOperator } from '@nuxt/content'
2
2
  import type { BadgeProps } from '@nuxt/ui'
3
3
  import type { MaybeRefOrGetter } from 'vue'
4
- import type { PageCollectionName } from '../types/content'
4
+ import type { PageCollectionName } from '../../../app/types/content'
5
5
  import { computed, toValue } from 'vue'
6
6
 
7
7
  export interface ArticleFilter {
@@ -1,42 +1,42 @@
1
- import type { ContentNavigationItem } from '@nuxt/content'
2
- import type { ContentSearchFile } from '@nuxt/ui'
3
- import { createContentSearchLoader } from '../utils/createContentSearchLoader'
4
-
5
- export interface ContentSearchDataLoaders {
6
- navigation?: () => Promise<ContentNavigationItem[]>
7
- files?: () => Promise<ContentSearchFile[]>
8
- }
9
-
10
- export function useContentSearchData(loaders: ContentSearchDataLoaders = {}) {
11
- const navigation = shallowRef<ContentNavigationItem[]>([])
12
- const files = shallowRef<ContentSearchFile[]>([])
13
- const status = ref<'idle' | 'pending' | 'success' | 'error'>('idle')
14
- const error = shallowRef<Error>()
15
-
16
- const loader = createContentSearchLoader({
17
- navigation: loaders.navigation ?? (() => $fetch<ContentNavigationItem[]>('/api/navigation.json')),
18
- files: loaders.files ?? (() => $fetch<ContentSearchFile[]>('/api/search.json')),
19
- }, {
20
- pending: () => {
21
- status.value = 'pending'
22
- error.value = undefined
23
- },
24
- success: (loadedNavigation, loadedFiles) => {
25
- navigation.value = loadedNavigation
26
- files.value = loadedFiles
27
- status.value = 'success'
28
- },
29
- error: (cause) => {
30
- error.value = cause
31
- status.value = 'error'
32
- },
33
- })
34
-
35
- return {
36
- navigation,
37
- files,
38
- status,
39
- error,
40
- load: loader.load,
41
- }
42
- }
1
+ import type { ContentNavigationItem } from '@nuxt/content'
2
+ import type { ContentSearchFile } from '@nuxt/ui'
3
+ import { createContentSearchLoader } from '../../../app/utils/createContentSearchLoader'
4
+
5
+ export interface ContentSearchDataLoaders {
6
+ navigation?: () => Promise<ContentNavigationItem[]>
7
+ files?: () => Promise<ContentSearchFile[]>
8
+ }
9
+
10
+ export function useContentSearchData(loaders: ContentSearchDataLoaders = {}) {
11
+ const navigation = shallowRef<ContentNavigationItem[]>([])
12
+ const files = shallowRef<ContentSearchFile[]>([])
13
+ const status = ref<'idle' | 'pending' | 'success' | 'error'>('idle')
14
+ const error = shallowRef<Error>()
15
+
16
+ const loader = createContentSearchLoader({
17
+ navigation: loaders.navigation ?? (() => $fetch<ContentNavigationItem[]>('/api/navigation.json')),
18
+ files: loaders.files ?? (() => $fetch<ContentSearchFile[]>('/api/search.json')),
19
+ }, {
20
+ pending: () => {
21
+ status.value = 'pending'
22
+ error.value = undefined
23
+ },
24
+ success: (loadedNavigation, loadedFiles) => {
25
+ navigation.value = loadedNavigation
26
+ files.value = loadedFiles
27
+ status.value = 'success'
28
+ },
29
+ error: (cause) => {
30
+ error.value = cause
31
+ status.value = 'error'
32
+ },
33
+ })
34
+
35
+ return {
36
+ navigation,
37
+ files,
38
+ status,
39
+ error,
40
+ load: loader.load,
41
+ }
42
+ }
@@ -1,7 +1,7 @@
1
1
  import type { PageCollectionItemBase, PageCollections } from '@nuxt/content'
2
2
  import type { AsyncData } from 'nuxt/app'
3
3
  import type { MaybeRefOrGetter } from 'vue'
4
- import type { PageCollectionName } from '../types/content'
4
+ import type { PageCollectionName } from '../../../app/types/content'
5
5
  import { computed, toValue } from 'vue'
6
6
 
7
7
  type PageForCollection<C extends PageCollectionName> = PageCollectionItemBase
@@ -1,6 +1,6 @@
1
1
  <script setup lang="ts" generic="C extends PageCollectionName = 'article'">
2
2
  import type { BreadcrumbItem } from '@nuxt/ui'
3
- import type { PageCollectionName } from '../types/content'
3
+ import type { PageCollectionName } from '../../../app/types/content'
4
4
 
5
5
  const props = defineProps<{
6
6
  path?: string
@@ -9,6 +9,7 @@ const props = defineProps<{
9
9
 
10
10
  const route = useRoute()
11
11
  const collection = computed(() => props.collection ?? 'article')
12
+ const surroundCollection = computed<PageCollectionName>(() => collection.value)
12
13
 
13
14
  const { data: page } = await usePageContent({
14
15
  path: () => props.path,
@@ -39,23 +40,10 @@ const header = computed(() => resolvePageHeader(page.value))
39
40
 
40
41
  const breadcrumbsBase = computed(() => (config.value.breadcrumbs ?? []) as BreadcrumbItem[])
41
42
 
42
- const breadcrumbItems = computed(() => {
43
- const baseItems = breadcrumbsBase.value.map((item, index) => ({
44
- ...item,
45
- ...(index === breadcrumbsBase.value.length - 1
46
- ? { ui: { ...item.ui, separator: 'hidden sm:flex' } }
47
- : {}),
48
- }))
49
-
50
- return [
51
- ...baseItems,
52
- {
53
- label: page.value?.title,
54
- to: page.value?.path,
55
- ui: { item: 'hidden sm:flex' },
56
- },
57
- ]
58
- })
43
+ const currentBreadcrumb = computed<BreadcrumbItem>(() => ({
44
+ label: page.value?.title,
45
+ to: page.value?.path,
46
+ }))
59
47
 
60
48
  const backLink = computed(() => {
61
49
  const lastBreadcrumb = breadcrumbsBase.value.at(-1)
@@ -78,9 +66,9 @@ const backLink = computed(() => {
78
66
  }"
79
67
  >
80
68
  <template #headline>
81
- <UBreadcrumb
82
- :ui="{ root: 'max-w-full' }"
83
- :items="breadcrumbItems"
69
+ <HBreadcrumbs
70
+ :items="breadcrumbsBase"
71
+ :current="currentBreadcrumb"
84
72
  />
85
73
  <HArticleHeadlineMeta :page="page" :collection="collection" />
86
74
  </template>
@@ -115,7 +103,7 @@ const backLink = computed(() => {
115
103
 
116
104
  <HSurround
117
105
  v-if="hasSurround"
118
- :collection="collection"
106
+ :collection="surroundCollection"
119
107
  v-bind="config.surround"
120
108
  :query="config.query"
121
109
  />
@@ -1,27 +1,27 @@
1
- <script setup lang="ts" generic="C extends PageCollectionName = 'page'">
2
- import type { PageCollectionItemBase } from '@nuxt/content'
3
- import type { PageCollectionName } from '../types/content'
1
+ <script setup lang="ts" generic="C extends PageCollectionName = 'page'">
2
+ import type { PageCollectionItemBase } from '@nuxt/content'
3
+ import type { PageCollectionName } from '../../../app/types/content'
4
4
 
5
- const {
6
- path,
7
- collection = 'page' as C,
8
- page: suppliedPage,
9
- } = defineProps<{
10
- path?: string
11
- collection?: C
12
- page?: PageCollectionItemBase | null
13
- }>()
5
+ const {
6
+ path,
7
+ collection = 'page' as C,
8
+ page: suppliedPage,
9
+ } = defineProps<{
10
+ path?: string
11
+ collection?: C
12
+ page?: PageCollectionItemBase | null
13
+ }>()
14
14
 
15
15
  const appConfig = useAppConfig()
16
16
  const route = useRoute()
17
17
 
18
- const fetched = suppliedPage === undefined
19
- ? await usePageContent<C>({
20
- path: () => path,
21
- collection: () => collection,
22
- })
23
- : undefined
24
- const page = computed(() => suppliedPage === undefined ? fetched?.data.value : suppliedPage)
18
+ const fetched = suppliedPage === undefined
19
+ ? await usePageContent<C>({
20
+ path: () => path,
21
+ collection: () => collection,
22
+ })
23
+ : undefined
24
+ const page = computed(() => suppliedPage === undefined ? fetched?.data.value : suppliedPage)
25
25
 
26
26
  const variant = computed(() => {
27
27
  if (typeof route.meta.variant === 'string' && route.meta.variant) {
@@ -32,7 +32,7 @@ const variant = computed(() => {
32
32
  return route.meta.layout
33
33
  }
34
34
 
35
- return collection as string
35
+ return collection as string
36
36
  })
37
37
  const { has } = useVariant(variant)
38
38
  const hasHeader = has('header')
@@ -41,7 +41,7 @@ const hasToc = has('toc')
41
41
  if (!page.value) {
42
42
  throw createError({
43
43
  statusCode: 404,
44
- statusMessage: `${collection} ${path || route.path} not found`,
44
+ statusMessage: `${collection} ${path || route.path} not found`,
45
45
  fatal: true,
46
46
  })
47
47
  }
@@ -1,6 +1,6 @@
1
1
  import type { CollectionItemBase, CollectionQueryBuilder, Collections } from '@nuxt/content'
2
2
  import type { UserProps } from '@nuxt/ui'
3
- import type { CollectionName } from '../types/content'
3
+ import type { CollectionName } from '../../../app/types/content'
4
4
 
5
5
  interface UserRecord extends CollectionItemBase {
6
6
  username: string
@@ -0,0 +1,7 @@
1
+ export default defineNuxtConfig({
2
+ $meta: { name: '@happydesigns/ui-content' },
3
+ extends: ['..'],
4
+ modules: ['@nuxt/content', 'nuxt-studio'],
5
+ components: [{ path: './components', pathPrefix: false, prefix: 'H' }],
6
+ studio: false,
7
+ })
@@ -1,11 +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
- })
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
+ })
@@ -1,11 +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
- })
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
+ })
@@ -1,7 +1,7 @@
1
1
  import type { PageCollections, SQLOperator } from '@nuxt/content'
2
2
  import type { H3Event } from 'h3'
3
- import type { SearchCollectionConfig, SearchConfig } from '../../app/types/config'
4
- import type { PageCollectionName } from '../../app/types/content'
3
+ import type { SearchCollectionConfig, SearchConfig } from '../../../app/types/config'
4
+ import type { PageCollectionName } from '../../../app/types/content'
5
5
 
6
6
  interface ConfigurableSearchQuery {
7
7
  where: (field: string, operator: SQLOperator, value?: unknown) => unknown
package/nuxt.config.ts CHANGED
@@ -1,28 +1,25 @@
1
- import { variantRegistry } from './schemas/variants'
2
-
3
- // https://nuxt.com/docs/api/configuration/nuxt-config
4
- export default defineNuxtConfig({
5
-
6
- $meta: {
7
- name: '@happydesigns/ui',
8
- },
9
-
10
- components: [
11
- { path: './components', pathPrefix: false, prefix: 'H' },
12
- ],
13
-
14
- devtools: { enabled: true },
15
-
16
- modules: [
17
- '@happydesigns/nuxt-variants',
18
- '@nuxt/ui',
19
- '@nuxt/content',
20
- 'nuxt-studio',
21
- ],
22
-
23
- variants: {
24
- registry: variantRegistry,
25
- },
26
-
27
- studio: false,
28
- })
1
+ import { variantRegistry } from './schemas/variants'
2
+
3
+ // https://nuxt.com/docs/api/configuration/nuxt-config
4
+ export default defineNuxtConfig({
5
+
6
+ $meta: {
7
+ name: '@happydesigns/ui',
8
+ },
9
+
10
+ components: [
11
+ { path: './components', pathPrefix: false, prefix: 'H' },
12
+ ],
13
+
14
+ devtools: { enabled: true },
15
+
16
+ modules: [
17
+ '@happydesigns/nuxt-variants',
18
+ '@nuxt/ui',
19
+ ],
20
+
21
+ variants: {
22
+ registry: variantRegistry,
23
+ },
24
+
25
+ })
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@happydesigns/ui",
3
3
  "type": "module",
4
- "version": "0.19.2",
4
+ "version": "0.20.0",
5
5
  "private": false,
6
6
  "packageManager": "pnpm@11.11.0",
7
7
  "description": "A reusable Nuxt foundation for content-driven happydesigns websites and applications.",
@@ -27,16 +27,21 @@
27
27
  ".": "./nuxt.config.ts",
28
28
  "./schemas": "./schemas/index.ts",
29
29
  "./styles.css": "./app/assets/css/styles.css",
30
- "./types": "./app/types/config.ts"
30
+ "./types": "./app/types/config.ts",
31
+ "./content": "./content/nuxt.config.ts"
31
32
  },
32
33
  "main": "./nuxt.config.ts",
33
34
  "files": [
34
35
  "app",
36
+ "content",
35
37
  "nuxt.config.ts",
36
38
  "schemas",
37
39
  "server",
38
40
  "shared"
39
41
  ],
42
+ "engines": {
43
+ "node": "^22.19.0 || ^24.11.0 || >=26.0.0"
44
+ },
40
45
  "publishConfig": {
41
46
  "access": "public"
42
47
  },
@@ -62,10 +67,11 @@
62
67
  "release:beta": "changelogen --release --versionSuffix beta.0"
63
68
  },
64
69
  "peerDependencies": {
65
- "tailwindcss": "^4.3.2"
70
+ "tailwindcss": "^4.3.2",
71
+ "vue": "^3.5.41"
66
72
  },
67
73
  "dependencies": {
68
- "@happydesigns/nuxt-variants": "^0.1.1",
74
+ "@happydesigns/nuxt-variants": "^0.2.0",
69
75
  "@iconify-json/heroicons": "^1.2.3",
70
76
  "@iconify-json/lucide": "^1.2.116",
71
77
  "@iconify-json/simple-icons": "^1.2.89",
@@ -1,10 +1,12 @@
1
+ import { defineVariantRegistry } from '@happydesigns/nuxt-variants/schemas'
2
+
1
3
  /**
2
4
  * Public variant registry shared by the Nuxt module and schema composition.
3
5
  *
4
6
  * Keeping the registry in one place guarantees that runtime inheritance and
5
7
  * Nuxt Content schemas are derived from the same explicit variant graph.
6
8
  */
7
- export const variantRegistry = {
9
+ export const variantRegistry = defineVariantRegistry({
8
10
  // Data features — schema only, no config
9
11
  dates: {},
10
12
  authors: {},
@@ -17,7 +19,7 @@ export const variantRegistry = {
17
19
  layout: {},
18
20
  separatorButtons: {},
19
21
 
20
- // UI features — config defined in app.config.ts
22
+ // UI features — values are supplied through app.config.ts.
21
23
  user: {},
22
24
  backButton: {},
23
25
  copyButton: {},
@@ -38,4 +40,4 @@ export const variantRegistry = {
38
40
  extends: ['layout', 'header', 'toc'],
39
41
  config: {},
40
42
  },
41
- }
43
+ })
@@ -10,14 +10,4 @@ declare module '@nuxt/schema' {
10
10
  }
11
11
  }
12
12
 
13
- declare module 'nuxt/schema' {
14
- interface AppConfigInput {
15
- app?: HAppConfigInput
16
- }
17
-
18
- interface AppConfig {
19
- app: HAppConfig
20
- }
21
- }
22
-
23
13
  export {}