@happydesigns/ui 0.19.3 → 0.20.1

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 (28) hide show
  1. package/README.md +28 -0
  2. package/app/components/MaintenancePage.vue +80 -0
  3. package/app/components/search/SiteSearch.client.vue +27 -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 +49 -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 +20 -20
  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 +29 -28
  26. package/package.json +25 -25
  27. /package/{app → content/app}/components/traits/Authors.vue +0 -0
  28. /package/{app → content/app}/composables/useArticleListQuery.ts +0 -0
package/README.md CHANGED
@@ -39,8 +39,36 @@ Run Nuxt preparation after changing dependencies or layer configuration:
39
39
  pnpm exec nuxt prepare
40
40
  ```
41
41
 
42
+ ## Maintenance page
43
+
44
+ For a branded temporary notice, use `HMaintenancePage` with title, description, actions and optional logo/tools/footer slots. Activation, routing and HTTP status stay application-owned. See [Maintenance page](docs/content/6.configuration/9.maintenance.md).
45
+
46
+ ## Site search
47
+
48
+ Render `<HSiteSearch />` once in the app shell and use `<UContentSearchButton />`
49
+ to open it. Configure navigation shortcuts with `app.search.links` and
50
+ `app.search.groups`. The base-layer search does not load content indexes or
51
+ activate Nuxt Content or Studio. See [Search](docs/content/6.configuration/8.content-search.md).
52
+
42
53
  ## Content collections
43
54
 
55
+ Applications using Nuxt Content extend `@happydesigns/ui/content` instead of
56
+ `@happydesigns/ui`. This optional layer includes article/content layouts,
57
+ `HContentPage`, `HSnippet`, content search, author lookup, navigation endpoints,
58
+ and Nuxt Studio (disabled unless configured by the application).
59
+
60
+ ```ts
61
+ export default defineNuxtConfig({
62
+ extends: ['@happydesigns/ui/content'],
63
+ })
64
+ ```
65
+
66
+ **Migration from 0.19.x:** change the layer entry point above if your application
67
+ uses these features. The base entry point now registers only Nuxt UI and variants;
68
+ Comark applications can keep it without initializing Nuxt Content or Studio.
69
+ The dependencies remain installed for the optional layer, but are not activated
70
+ by the base layer.
71
+
44
72
  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
73
 
46
74
  ```ts
@@ -0,0 +1,80 @@
1
+ <script setup lang="ts">
2
+ import type { ButtonProps } from '@nuxt/ui'
3
+
4
+ withDefaults(defineProps<{
5
+ title: string
6
+ description?: string
7
+ icon?: string
8
+ iconColor?: 'primary' | 'secondary'
9
+ mainId?: string
10
+ actions?: ButtonProps[]
11
+ }>(), { actions: () => [], mainId: 'main-content', iconColor: 'primary' })
12
+ </script>
13
+
14
+ <template>
15
+ <div class="flex min-h-dvh flex-col bg-default text-default">
16
+ <header v-if="$slots.logo || $slots.tools" class="border-b border-default">
17
+ <UContainer class="flex min-h-16 max-w-[88rem] items-center justify-between gap-6 py-3">
18
+ <slot name="logo" />
19
+ <slot name="tools" />
20
+ </UContainer>
21
+ </header>
22
+ <main :id="mainId" tabindex="-1" class="holding-surface relative isolate flex flex-1 items-center px-0 py-16 sm:py-20">
23
+ <UContainer class="relative w-full">
24
+ <div class="mx-auto max-w-3xl text-center">
25
+ <UIcon v-if="icon" :name="icon" class="mb-6 size-10 sm:size-12" :class="iconColor === 'secondary' ? 'text-secondary' : 'text-primary'" aria-hidden="true" />
26
+ <h1 class="text-4xl font-semibold tracking-tight text-balance text-highlighted sm:text-5xl">
27
+ {{ title }}
28
+ </h1>
29
+ <p v-if="description" class="mx-auto mt-6 max-w-xl text-lg leading-relaxed text-muted sm:text-xl">
30
+ {{ description }}
31
+ </p>
32
+ <slot />
33
+ <div v-if="actions.length || $slots.actions" class="mt-8 flex flex-wrap justify-center gap-3 sm:mt-10">
34
+ <slot name="actions">
35
+ <UButton v-for="(action, index) in actions" :key="index" v-bind="action" />
36
+ </slot>
37
+ </div>
38
+ </div>
39
+ </UContainer>
40
+ </main>
41
+ <footer v-if="$slots.footer" class="border-t border-default py-6 text-sm text-muted">
42
+ <UContainer><slot name="footer" /></UContainer>
43
+ </footer>
44
+ </div>
45
+ </template>
46
+
47
+ <style scoped>
48
+ .holding-surface {
49
+ background: var(--ui-bg);
50
+ background-image: radial-gradient(ellipse at center, transparent 15%, color-mix(in srgb, var(--ui-bg-muted) 20%, var(--ui-bg)) 100%);
51
+ }
52
+ .holding-surface::before {
53
+ content: '';
54
+ position: absolute;
55
+ inset: 0;
56
+ z-index: -1;
57
+ pointer-events: none;
58
+ opacity: .13;
59
+ background-image: radial-gradient(ellipse 3px 1px, var(--ui-primary) 95%, transparent), radial-gradient(ellipse 1px 3px, var(--ui-primary) 95%, transparent);
60
+ background-size: 44px 44px;
61
+ mask-image: radial-gradient(ellipse at center, transparent 25%, black 100%);
62
+ }
63
+ /* Static monochrome grain dithers the gradient without filtering the content. */
64
+ .holding-surface::after {
65
+ content: '';
66
+ position: absolute;
67
+ inset: 0;
68
+ z-index: -1;
69
+ pointer-events: none;
70
+ opacity: .045;
71
+ background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'%3E%3Cfilter id='grain' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' seed='7' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Cpath fill='%23808080' filter='url(%23grain)' d='M0 0h160v160H0z'/%3E%3C/svg%3E");
72
+ background-size: 160px 160px;
73
+ }
74
+ @media (forced-colors: active) {
75
+ .holding-surface::before,
76
+ .holding-surface::after {
77
+ display: none;
78
+ }
79
+ }
80
+ </style>
@@ -0,0 +1,27 @@
1
+ <script setup lang="ts">
2
+ import type { CommandPaletteGroup, ContentSearchProps } from '@nuxt/ui'
3
+
4
+ const props = defineProps<Pick<ContentSearchProps, 'files' | 'navigation' | 'loading' | 'groups'>>()
5
+ const appConfig = useAppConfig()
6
+ const search = computed(() => appConfig.app.search)
7
+ const searchTerm = ref('')
8
+ const groups = computed<CommandPaletteGroup[]>(() => [
9
+ ...props.groups ?? [],
10
+ ...search.value.groups ?? [],
11
+ ])
12
+ </script>
13
+
14
+ <template>
15
+ <UContentSearch
16
+ v-model:search-term="searchTerm"
17
+ :title="search.title"
18
+ :description="search.description"
19
+ :placeholder="search.placeholder"
20
+ :links="search.links"
21
+ :groups="groups"
22
+ :files="props.files"
23
+ :navigation="props.navigation"
24
+ :loading="props.loading"
25
+ :fuse="{ resultLimit: search.resultLimit }"
26
+ />
27
+ </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,49 @@
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 { navigation, files, status, error, load } = useContentSearchData()
8
+
9
+ const groups = computed<CommandPaletteGroup[]>(() => {
10
+ if (!error.value) {
11
+ return []
12
+ }
13
+
14
+ return [
15
+ {
16
+ id: 'search-error',
17
+ label: search.value.error?.title,
18
+ ignoreFilter: true,
19
+ items: [
20
+ {
21
+ label: search.value.error?.retryLabel,
22
+ description: search.value.error?.description,
23
+ icon: 'i-lucide-refresh-cw',
24
+ onSelect: () => void load(),
25
+ },
26
+ ],
27
+ },
28
+ ]
29
+ })
30
+
31
+ watch(open, (isOpen) => {
32
+ if (isOpen) {
33
+ void load().then(() => {
34
+ if (error.value) {
35
+ console.error('Failed to load the search index.', error.value)
36
+ }
37
+ })
38
+ }
39
+ }, { immediate: true })
40
+ </script>
41
+
42
+ <template>
43
+ <HSiteSearch
44
+ :groups="groups"
45
+ :files="files"
46
+ :navigation="navigation"
47
+ :loading="status === 'pending'"
48
+ />
49
+ </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,15 +1,15 @@
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
- const props = defineProps<{
6
- path?: string
7
- collection?: C
8
- }>()
9
-
10
- const route = useRoute()
11
- const collection = computed(() => props.collection ?? 'article')
12
- const surroundCollection = computed<PageCollectionName>(() => collection.value)
5
+ const props = defineProps<{
6
+ path?: string
7
+ collection?: C
8
+ }>()
9
+
10
+ const route = useRoute()
11
+ const collection = computed(() => props.collection ?? 'article')
12
+ const surroundCollection = computed<PageCollectionName>(() => collection.value)
13
13
 
14
14
  const { data: page } = await usePageContent({
15
15
  path: () => props.path,
@@ -40,10 +40,10 @@ const header = computed(() => resolvePageHeader(page.value))
40
40
 
41
41
  const breadcrumbsBase = computed(() => (config.value.breadcrumbs ?? []) as BreadcrumbItem[])
42
42
 
43
- const currentBreadcrumb = computed<BreadcrumbItem>(() => ({
44
- label: page.value?.title,
45
- to: page.value?.path,
46
- }))
43
+ const currentBreadcrumb = computed<BreadcrumbItem>(() => ({
44
+ label: page.value?.title,
45
+ to: page.value?.path,
46
+ }))
47
47
 
48
48
  const backLink = computed(() => {
49
49
  const lastBreadcrumb = breadcrumbsBase.value.at(-1)
@@ -66,10 +66,10 @@ const backLink = computed(() => {
66
66
  }"
67
67
  >
68
68
  <template #headline>
69
- <HBreadcrumbs
70
- :items="breadcrumbsBase"
71
- :current="currentBreadcrumb"
72
- />
69
+ <HBreadcrumbs
70
+ :items="breadcrumbsBase"
71
+ :current="currentBreadcrumb"
72
+ />
73
73
  <HArticleHeadlineMeta :page="page" :collection="collection" />
74
74
  </template>
75
75
  <HArticleHeaderBody :page="page" :collection="collection">
@@ -101,9 +101,9 @@ const backLink = computed(() => {
101
101
  v-bind="config.separator"
102
102
  />
103
103
 
104
- <HSurround
105
- v-if="hasSurround"
106
- :collection="surroundCollection"
104
+ <HSurround
105
+ v-if="hasSurround"
106
+ :collection="surroundCollection"
107
107
  v-bind="config.surround"
108
108
  :query="config.query"
109
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,29 @@
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
+ ui: {
22
+ content: true,
23
+ },
24
+
25
+ variants: {
26
+ registry: variantRegistry,
27
+ },
28
+
29
+ })
package/package.json CHANGED
@@ -1,9 +1,8 @@
1
1
  {
2
2
  "name": "@happydesigns/ui",
3
3
  "type": "module",
4
- "version": "0.19.3",
4
+ "version": "0.20.1",
5
5
  "private": false,
6
- "packageManager": "pnpm@11.11.0",
7
6
  "description": "A reusable Nuxt foundation for content-driven happydesigns websites and applications.",
8
7
  "author": "happydesigns",
9
8
  "homepage": "https://github.com/happydesigns/ui#readme",
@@ -27,11 +26,13 @@
27
26
  ".": "./nuxt.config.ts",
28
27
  "./schemas": "./schemas/index.ts",
29
28
  "./styles.css": "./app/assets/css/styles.css",
30
- "./types": "./app/types/config.ts"
29
+ "./types": "./app/types/config.ts",
30
+ "./content": "./content/nuxt.config.ts"
31
31
  },
32
32
  "main": "./nuxt.config.ts",
33
33
  "files": [
34
34
  "app",
35
+ "content",
35
36
  "nuxt.config.ts",
36
37
  "schemas",
37
38
  "server",
@@ -43,27 +44,6 @@
43
44
  "publishConfig": {
44
45
  "access": "public"
45
46
  },
46
- "scripts": {
47
- "dev": "nuxt dev playground",
48
- "docs": "nuxt dev docs",
49
- "docs:build": "nuxt generate docs && node scripts/validate-docs-output.mjs",
50
- "docs:build:server": "nuxt build docs",
51
- "prepare": "nuxt prepare && nuxt prepare playground",
52
- "build": "nuxt build playground",
53
- "generate": "nuxt generate playground && node scripts/validate-playground-output.mjs",
54
- "package:check": "node scripts/validate-package.mjs",
55
- "consumer:check": "node scripts/validate-consumer.mjs",
56
- "preview": "nuxt preview playground",
57
- "lint": "eslint .",
58
- "lint:fix": "eslint . --fix",
59
- "typecheck": "nuxt typecheck && nuxt typecheck playground",
60
- "test": "vitest run",
61
- "test:watch": "vitest",
62
- "release": "changelogen --release",
63
- "release:pre": "changelogen --release --prerelease",
64
- "release:alpha": "changelogen --release --versionSuffix alpha.0",
65
- "release:beta": "changelogen --release --versionSuffix beta.0"
66
- },
67
47
  "peerDependencies": {
68
48
  "tailwindcss": "^4.3.2",
69
49
  "vue": "^3.5.41"
@@ -95,5 +75,25 @@
95
75
  },
96
76
  "resolutions": {
97
77
  "@happydesigns/ui": "workspace:*"
78
+ },
79
+ "scripts": {
80
+ "dev": "nuxt dev playground",
81
+ "docs": "nuxt dev docs",
82
+ "docs:build": "nuxt generate docs && node scripts/validate-docs-output.mjs",
83
+ "docs:build:server": "nuxt build docs",
84
+ "build": "nuxt build playground && node scripts/validate-playground-output.mjs",
85
+ "generate": "nuxt generate playground && node scripts/validate-playground-output.mjs",
86
+ "package:check": "node scripts/validate-package.mjs",
87
+ "consumer:check": "node scripts/validate-consumer.mjs",
88
+ "preview": "nuxt preview playground",
89
+ "lint": "eslint .",
90
+ "lint:fix": "eslint . --fix",
91
+ "typecheck": "nuxt typecheck && nuxt typecheck playground",
92
+ "test": "vitest run",
93
+ "test:watch": "vitest",
94
+ "release": "changelogen --release",
95
+ "release:pre": "changelogen --release --prerelease",
96
+ "release:alpha": "changelogen --release --versionSuffix alpha.0",
97
+ "release:beta": "changelogen --release --versionSuffix beta.0"
98
98
  }
99
- }
99
+ }