@happydesigns/ui 0.13.5 → 0.14.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 (37) hide show
  1. package/README.md +94 -94
  2. package/app/app.config.ts +168 -169
  3. package/app/app.vue +11 -0
  4. package/app/components/article/ArticleGrid.vue +125 -149
  5. package/app/components/article/ArticleHeaderBody.vue +20 -20
  6. package/app/components/article/ArticleHeadlineMeta.vue +26 -26
  7. package/app/components/article/ArticleList.vue +80 -95
  8. package/app/components/article/ArticlePage.vue +15 -14
  9. package/app/components/footer/FooterColumnHeading.vue +5 -5
  10. package/app/components/footer/FooterCopyright.vue +29 -29
  11. package/app/components/traits/Authors.vue +19 -20
  12. package/app/components/traits/BackButton.vue +15 -26
  13. package/app/components/traits/Category.vue +9 -9
  14. package/app/components/traits/CopyButton.vue +32 -39
  15. package/app/components/traits/Dates.vue +20 -20
  16. package/app/components/traits/Links.vue +17 -17
  17. package/app/components/traits/Location.vue +20 -20
  18. package/app/components/traits/Separator.vue +21 -26
  19. package/app/components/traits/SeparatorButtons.vue +53 -56
  20. package/app/components/traits/Surround.vue +48 -60
  21. package/app/components/traits/Toc.vue +16 -16
  22. package/app/composables/useArticleList.ts +24 -26
  23. package/app/composables/useArticleListQuery.ts +54 -0
  24. package/app/composables/useCategoryBadge.ts +27 -27
  25. package/app/composables/useClipboard.ts +26 -26
  26. package/app/composables/usePageContent.ts +18 -18
  27. package/app/composables/usePageSeo.ts +30 -30
  28. package/app/layouts/article.vue +117 -125
  29. package/app/layouts/content.vue +57 -65
  30. package/app/layouts/default.vue +3 -12
  31. package/app/types/config.ts +13 -6
  32. package/content.config.ts +6 -6
  33. package/nuxt.config.ts +80 -80
  34. package/package.json +3 -3
  35. package/schemas/collections.ts +46 -46
  36. package/schemas/index.ts +2 -2
  37. package/schemas/traits.ts +90 -90
@@ -1,29 +1,29 @@
1
- <script setup lang="ts">
2
- const props = defineProps<{
3
- copyrightYear?: number
4
- copyrightHolder?: string
5
- copyrightHomepage?: string
6
- }>()
7
-
8
- const appConfig = useAppConfig()
9
-
10
- 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 ?? ''
13
- </script>
14
-
15
- <template>
16
- <div>
17
- <template v-if="$slots.copyright">
18
- <slot name="copyright" :copyright-year :copyright-homepage :copyright-holder />
19
- </template>
20
- <template v-else>
21
- <p class="text-muted text-sm">
22
- Copyright © {{ copyrightYear }}
23
- <ULink :to="copyrightHomepage" target="_blank">
24
- {{ copyrightHolder }}
25
- </ULink>
26
- </p>
27
- </template>
28
- </div>
29
- </template>
1
+ <script setup lang="ts">
2
+ const props = defineProps<{
3
+ copyrightYear?: number
4
+ copyrightHolder?: string
5
+ copyrightHomepage?: string
6
+ }>()
7
+
8
+ const appConfig = useAppConfig()
9
+
10
+ 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 ?? ''
13
+ </script>
14
+
15
+ <template>
16
+ <div>
17
+ <template v-if="$slots.copyright">
18
+ <slot name="copyright" :copyright-year :copyright-homepage :copyright-holder />
19
+ </template>
20
+ <template v-else>
21
+ <p class="text-muted text-sm">
22
+ Copyright © {{ copyrightYear }}
23
+ <ULink :to="copyrightHomepage" target="_blank">
24
+ {{ copyrightHolder }}
25
+ </ULink>
26
+ </p>
27
+ </template>
28
+ </div>
29
+ </template>
@@ -1,20 +1,19 @@
1
- <script setup lang="ts">
2
- const props = defineProps<{
3
- authors?: string[]
4
- target?: string
5
- }>()
6
-
7
- const { config } = useVariant('user')
8
-
9
- const userProps = computed(() => ({ ...(config.value.user ?? {}), ...(props.target ? { target: props.target } : {}) }))
10
-
11
- const resolvedAuthors = await resolveUsers(props.authors || [], userProps.value)
12
- </script>
13
-
14
- <template>
15
- <UUser
16
- v-for="(author, index) in resolvedAuthors"
17
- :key="index"
18
- v-bind="author"
19
- />
20
- </template>
1
+ <script setup lang="ts">
2
+ const props = defineProps<{
3
+ authors?: string[]
4
+ target?: string
5
+ config?: VariantConfigOf<'user'>
6
+ }>()
7
+
8
+ const userProps = computed(() => ({ ...(props.config?.user ?? {}), ...(props.target ? { target: props.target } : {}) }))
9
+
10
+ const resolvedAuthors = await resolveUsers(props.authors || [], userProps.value)
11
+ </script>
12
+
13
+ <template>
14
+ <UUser
15
+ v-for="(author, index) in resolvedAuthors"
16
+ :key="index"
17
+ v-bind="author"
18
+ />
19
+ </template>
@@ -1,26 +1,15 @@
1
- <script setup lang="ts">
2
- import type { RouteLocationRaw } from 'vue-router'
3
-
4
- const props = defineProps<{
5
- to?: RouteLocationRaw
6
- icon?: string
7
- label?: string
8
- }>()
9
-
10
- const { config } = useVariant('backButton')
11
-
12
- const resolvedIcon = computed(() => props.icon ?? config.value.backButton?.icon)
13
- const resolvedLabel = computed(() => props.label ?? config.value.backButton?.label)
14
- const resolvedTo = computed(() => props.to ?? config.value.backButton?.to)
15
- </script>
16
-
17
- <template>
18
- <UButton
19
- color="primary"
20
- variant="ghost"
21
- :icon="resolvedIcon"
22
- :to="resolvedTo"
23
- >
24
- {{ resolvedLabel }}
25
- </UButton>
26
- </template>
1
+ <script setup lang="ts">
2
+ import type { RouteLocationRaw } from 'vue-router'
3
+
4
+ defineProps<{
5
+ to?: RouteLocationRaw
6
+ icon?: string
7
+ label?: string
8
+ }>()
9
+ </script>
10
+
11
+ <template>
12
+ <UButton color="primary" variant="ghost" :icon="icon" :to="to">
13
+ {{ label }}
14
+ </UButton>
15
+ </template>
@@ -1,9 +1,9 @@
1
- <script setup lang="ts">
2
- defineProps<{
3
- category?: string
4
- }>()
5
- </script>
6
-
7
- <template>
8
- <span class="text-primary-500 dark:text-primary-400 font-medium">{{ category }}</span>
9
- </template>
1
+ <script setup lang="ts">
2
+ defineProps<{
3
+ category?: string
4
+ }>()
5
+ </script>
6
+
7
+ <template>
8
+ <span class="text-primary-500 dark:text-primary-400 font-medium">{{ category }}</span>
9
+ </template>
@@ -1,39 +1,32 @@
1
- <script setup lang="ts">
2
- const props = defineProps<{
3
- path?: string
4
- icon?: string
5
- label?: string
6
- successIcon?: string
7
- successLabel?: string
8
- }>()
9
-
10
- const { config } = useVariant('copyButton')
11
-
12
- const resolvedIcon = computed(() => props.icon ?? config.value.copyButton?.icon)
13
- const resolvedLabel = computed(() => props.label ?? config.value.copyButton?.label)
14
- const resolvedSuccessIcon = computed(() => props.successIcon ?? config.value.copyButton?.successIcon)
15
- const resolvedSuccessLabel = computed(() => props.successLabel ?? config.value.copyButton?.successLabel)
16
-
17
- const { copy } = useClipboard()
18
- const url = useRequestURL()
19
- const route = useRoute()
20
-
21
- function copyLink() {
22
- copy(`${url.origin}${props.path ?? route.path}`, {
23
- id: 'article-copy-link',
24
- title: resolvedSuccessLabel.value,
25
- icon: resolvedSuccessIcon.value,
26
- })
27
- }
28
- </script>
29
-
30
- <template>
31
- <UButton
32
- :icon="resolvedIcon"
33
- variant="ghost"
34
- color="neutral"
35
- @click="copyLink"
36
- >
37
- {{ resolvedLabel }}
38
- </UButton>
39
- </template>
1
+ <script setup lang="ts">
2
+ const props = defineProps<{
3
+ path?: string
4
+ icon?: string
5
+ label?: string
6
+ successIcon?: string
7
+ successLabel?: string
8
+ }>()
9
+
10
+ const { copy } = useClipboard()
11
+ const url = useRequestURL()
12
+ const route = useRoute()
13
+
14
+ function copyLink() {
15
+ copy(`${url.origin}${props.path ?? route.path}`, {
16
+ id: 'article-copy-link',
17
+ title: props.successLabel,
18
+ icon: props.successIcon,
19
+ })
20
+ }
21
+ </script>
22
+
23
+ <template>
24
+ <UButton
25
+ :icon="icon"
26
+ variant="ghost"
27
+ color="neutral"
28
+ @click="copyLink"
29
+ >
30
+ {{ label }}
31
+ </UButton>
32
+ </template>
@@ -1,20 +1,20 @@
1
- <script setup lang="ts">
2
- import formatDate from '~/utils/formatDate'
3
-
4
- defineProps<{
5
- date?: string
6
- dateEnd?: string
7
- }>()
8
- </script>
9
-
10
- <template>
11
- <div class="all:flex items-center space-x-2">
12
- <UIcon name="i-lucide-calendar" class="size-4" />
13
- <time>
14
- {{ formatDate(date) }}
15
- <template v-if="dateEnd && date !== dateEnd">
16
- - {{ formatDate(dateEnd) }}
17
- </template>
18
- </time>
19
- </div>
20
- </template>
1
+ <script setup lang="ts">
2
+ import formatDate from '~/utils/formatDate'
3
+
4
+ defineProps<{
5
+ date?: string
6
+ dateEnd?: string
7
+ }>()
8
+ </script>
9
+
10
+ <template>
11
+ <div class="all:flex items-center space-x-2">
12
+ <UIcon name="i-lucide-calendar" class="size-4" />
13
+ <time>
14
+ {{ formatDate(date) }}
15
+ <template v-if="dateEnd && date !== dateEnd">
16
+ - {{ formatDate(dateEnd) }}
17
+ </template>
18
+ </time>
19
+ </div>
20
+ </template>
@@ -1,17 +1,17 @@
1
- <script setup lang="ts">
2
- import type { ButtonProps } from '@nuxt/ui'
3
-
4
- defineProps<{
5
- links?: ButtonProps[]
6
- }>()
7
- </script>
8
-
9
- <template>
10
- <UButton
11
- v-for="(link, index) in links"
12
- :key="index"
13
- variant="subtle"
14
- size="sm"
15
- v-bind="link"
16
- />
17
- </template>
1
+ <script setup lang="ts">
2
+ import type { ButtonProps } from '@nuxt/ui'
3
+
4
+ defineProps<{
5
+ links?: ButtonProps[]
6
+ }>()
7
+ </script>
8
+
9
+ <template>
10
+ <UButton
11
+ v-for="(link, index) in links"
12
+ :key="index"
13
+ variant="subtle"
14
+ size="sm"
15
+ v-bind="link"
16
+ />
17
+ </template>
@@ -1,20 +1,20 @@
1
- <script setup lang="ts">
2
- defineProps<{
3
- location?: { url?: string, name?: string }
4
- }>()
5
- </script>
6
-
7
- <template>
8
- <div class="all:flex items-center space-x-2">
9
- <UIcon name="i-lucide-map-pin" class="size-4" />
10
- <NuxtLink
11
- v-if="location?.url"
12
- :to="location.url"
13
- target="_blank"
14
- class="hover:text-primary transition-colors underline decoration-dotted underline-offset-4"
15
- >
16
- {{ location.name }}
17
- </NuxtLink>
18
- <span v-else>{{ location?.name }}</span>
19
- </div>
20
- </template>
1
+ <script setup lang="ts">
2
+ defineProps<{
3
+ location?: { url?: string, name?: string }
4
+ }>()
5
+ </script>
6
+
7
+ <template>
8
+ <div class="all:flex items-center space-x-2">
9
+ <UIcon name="i-lucide-map-pin" class="size-4" />
10
+ <NuxtLink
11
+ v-if="location?.url"
12
+ :to="location.url"
13
+ target="_blank"
14
+ class="hover:text-primary transition-colors underline decoration-dotted underline-offset-4"
15
+ >
16
+ {{ location.name }}
17
+ </NuxtLink>
18
+ <span v-else>{{ location?.name }}</span>
19
+ </div>
20
+ </template>
@@ -1,26 +1,21 @@
1
- <script setup lang="ts">
2
- import type { ActionButton } from '~/types/config'
3
-
4
- const props = defineProps<{
5
- stem?: string
6
- extension?: string
7
- buttons?: ActionButton[]
8
- separator?: string
9
- }>()
10
-
11
- const { config } = useVariant('separator')
12
-
13
- const resolvedButtons = computed(() => props.buttons ?? config.value.separator?.buttons ?? [])
14
- const resolvedSeparator = computed(() => props.separator ?? config.value.separator?.separator)
15
-
16
- const hasButtons = computed(() => resolvedButtons.value.length > 0)
17
- </script>
18
-
19
- <template>
20
- <USeparator v-if="!hasButtons" class="mt-8" />
21
- <USeparator v-else class="mt-8">
22
- <div class="all:flex items-center gap-2 text-sm text-muted">
23
- <HSeparatorButtons :stem="stem" :extension="extension" :buttons="resolvedButtons" :separator="resolvedSeparator" />
24
- </div>
25
- </USeparator>
26
- </template>
1
+ <script setup lang="ts">
2
+ import type { ActionButton } from '~/types/config'
3
+
4
+ const props = defineProps<{
5
+ stem?: string
6
+ extension?: string
7
+ buttons?: ActionButton[]
8
+ separator?: string
9
+ }>()
10
+
11
+ const hasButtons = computed(() => (props.buttons?.length ?? 0) > 0)
12
+ </script>
13
+
14
+ <template>
15
+ <USeparator v-if="!hasButtons" class="mt-8" />
16
+ <USeparator v-else class="mt-8">
17
+ <div class="all:flex items-center gap-2 text-sm text-muted">
18
+ <HSeparatorButtons :stem="stem" :extension="extension" :buttons="buttons" :separator="separator" />
19
+ </div>
20
+ </USeparator>
21
+ </template>
@@ -1,56 +1,53 @@
1
- <script setup lang="ts">
2
- import type { ActionButton } from '~/types/config'
3
-
4
- const props = defineProps<{
5
- stem?: string
6
- extension?: string
7
- buttons?: ActionButton[]
8
- separator?: string
9
- }>()
10
-
11
- const { config } = useVariant('separator')
12
-
13
- const resolvedButtons = computed(() => props.buttons ?? config.value.separator?.buttons ?? [])
14
- const resolvedSeparator = computed(() => props.separator ?? config.value.separator?.separator)
15
-
16
- const appConfig = useAppConfig()
17
-
18
- const editLink = computed(() => {
19
- const { repo, branch, dir } = appConfig.app.meta.github || {}
20
- if (!repo || !props.stem)
21
- return null
22
-
23
- const extension = props.extension || 'md'
24
- return `https://github.com/${repo}/edit/${branch}/${dir}/${props.stem}.${extension}`
25
- })
26
-
27
- const reportLink = computed(() => {
28
- const repo = appConfig.app.meta.github?.repo
29
- return repo ? `https://github.com/${repo}/issues/new` : null
30
- })
31
-
32
- const buttons = computed(() =>
33
- resolvedButtons.value.flatMap((btn) => {
34
- let to = btn.to
35
- if (btn.type === 'github-edit')
36
- to = editLink.value ?? undefined
37
- else if (btn.type === 'report-github-issue')
38
- to = reportLink.value ?? undefined
39
- return to ? [{ ...btn, to }] : []
40
- }),
41
- )
42
- </script>
43
-
44
- <template>
45
- <template v-for="(btn, index) in buttons" :key="index">
46
- <template v-if="index > 0">
47
- {{ resolvedSeparator }}
48
- </template>
49
- <UButton
50
- variant="link"
51
- color="neutral"
52
- :ui="{ leadingIcon: 'size-4' }"
53
- v-bind="btn"
54
- />
55
- </template>
56
- </template>
1
+ <script setup lang="ts">
2
+ import type { ActionButton } from '~/types/config'
3
+
4
+ const props = withDefaults(defineProps<{
5
+ stem?: string
6
+ extension?: string
7
+ buttons?: ActionButton[]
8
+ separator?: string
9
+ }>(), {
10
+ buttons: () => [],
11
+ })
12
+
13
+ const appConfig = useAppConfig()
14
+
15
+ const editLink = computed(() => {
16
+ const { repo, branch, dir } = appConfig.app.meta.github || {}
17
+ if (!repo || !props.stem)
18
+ return null
19
+
20
+ const extension = props.extension || 'md'
21
+ return `https://github.com/${repo}/edit/${branch}/${dir}/${props.stem}.${extension}`
22
+ })
23
+
24
+ const reportLink = computed(() => {
25
+ const repo = appConfig.app.meta.github?.repo
26
+ return repo ? `https://github.com/${repo}/issues/new` : null
27
+ })
28
+
29
+ const buttons = computed(() =>
30
+ props.buttons.flatMap((btn) => {
31
+ let to = btn.to
32
+ if (btn.type === 'github-edit')
33
+ to = editLink.value ?? undefined
34
+ else if (btn.type === 'report-github-issue')
35
+ to = reportLink.value ?? undefined
36
+ return to ? [{ ...btn, to }] : []
37
+ }),
38
+ )
39
+ </script>
40
+
41
+ <template>
42
+ <template v-for="(btn, index) in buttons" :key="index">
43
+ <template v-if="index > 0">
44
+ {{ separator }}
45
+ </template>
46
+ <UButton
47
+ variant="link"
48
+ color="neutral"
49
+ :ui="{ leadingIcon: 'size-4' }"
50
+ v-bind="btn"
51
+ />
52
+ </template>
53
+ </template>
@@ -1,60 +1,48 @@
1
- <script setup lang="ts" generic="C extends keyof PageCollections = 'article'">
2
- import type { PageCollections } from '@nuxt/content'
3
-
4
- const props = withDefaults(defineProps<{
5
- collection?: C
6
- show?: boolean
7
- prevIcon?: string
8
- nextIcon?: string
9
- fields?: string[]
10
- where?: any[]
11
- order?: { field: string, direction: 'ASC' | 'DESC' } | false
12
- }>(), {
13
- order: undefined,
14
- })
15
-
16
- const { config } = useVariant(() => props.collection || 'article')
17
- const vc = computed(() => config.value as any)
18
-
19
- const resolvedShow = computed(() => props.show ?? vc.value.surround?.show)
20
- const resolvedPrevIcon = computed(() => props.prevIcon ?? vc.value.surround?.prevIcon)
21
- const resolvedNextIcon = computed(() => props.nextIcon ?? vc.value.surround?.nextIcon)
22
-
23
- const route = useRoute()
24
-
25
- const { data: surround } = await useAsyncData(
26
- `surround-${String(props.collection || 'article')}-${route.path}`,
27
- () => {
28
- const colName = (props.collection || 'article') as any
29
- const qc = vc.value.query || {}
30
-
31
- const fields = (props.fields || qc.fields || ['title', 'description', 'status']) as any
32
- const order = props.order !== undefined ? props.order : qc.order
33
- const where = props.where || qc.where || [{ field: 'status', operator: '=', value: 'published' }]
34
-
35
- let query = queryCollectionItemSurroundings(colName, route.path, { fields })
36
-
37
- if (where && Array.isArray(where)) {
38
- where.forEach((filter) => {
39
- query = query.where(filter.field as any, filter.operator, filter.value)
40
- })
41
- }
42
-
43
- if (order) {
44
- query = query.order(order.field as any, order.direction)
45
- }
46
-
47
- return query
48
- },
49
- )
50
- </script>
51
-
52
- <template>
53
- <div v-if="resolvedShow && surround?.length" class="mt-12">
54
- <UContentSurround
55
- :surround="surround"
56
- :prev-icon="resolvedPrevIcon"
57
- :next-icon="resolvedNextIcon"
58
- />
59
- </div>
60
- </template>
1
+ <script setup lang="ts" generic="C extends keyof PageCollections ">
2
+ import type { PageCollections } from '@nuxt/content'
3
+ import type { QueryConfig } from '~/types/config'
4
+
5
+ const props = defineProps<{
6
+ collection: C
7
+ show?: boolean
8
+ prevIcon?: string
9
+ nextIcon?: string
10
+ query?: QueryConfig
11
+ }>()
12
+
13
+ const route = useRoute()
14
+
15
+ const { data: surround } = await useAsyncData(
16
+ `surround-${String(props.collection || 'article')}-${route.path}`,
17
+ () => {
18
+ const colName = (props.collection || 'article') as any
19
+ const qc = props.query || {}
20
+
21
+ const fields = (qc.fields || ['title', 'description', 'status']) as any
22
+ const order = qc.order
23
+ const where = qc.where || [{ field: 'status', operator: '=', value: 'published' }]
24
+
25
+ let query = queryCollectionItemSurroundings(colName, route.path, { fields })
26
+
27
+ where.forEach((filter) => {
28
+ query = query.where(filter.field as any, filter.operator as any, filter.value)
29
+ })
30
+
31
+ if (order) {
32
+ query = query.order(order.field as any, order.direction)
33
+ }
34
+
35
+ return query
36
+ },
37
+ )
38
+ </script>
39
+
40
+ <template>
41
+ <div v-if="show && surround?.some(Boolean)" class="mt-12">
42
+ <UContentSurround
43
+ :surround="surround"
44
+ :prev-icon="prevIcon"
45
+ :next-icon="nextIcon"
46
+ />
47
+ </div>
48
+ </template>
@@ -1,16 +1,16 @@
1
- <script setup lang="ts">
2
- const props = defineProps<{
3
- links?: any[]
4
- title?: string
5
- }>()
6
-
7
- const appConfig = useAppConfig()
8
- </script>
9
-
10
- <template>
11
- <UContentToc
12
- v-if="links?.length"
13
- :links="links"
14
- :title="title || appConfig.app.toc?.title"
15
- />
16
- </template>
1
+ <script setup lang="ts">
2
+ defineProps<{
3
+ links?: any[]
4
+ title?: string
5
+ }>()
6
+
7
+ const appConfig = useAppConfig()
8
+ </script>
9
+
10
+ <template>
11
+ <UContentToc
12
+ v-if="links?.length"
13
+ :links="links"
14
+ :title="title || appConfig.app.toc?.title"
15
+ />
16
+ </template>