@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.
- package/README.md +94 -94
- package/app/app.config.ts +168 -169
- package/app/app.vue +11 -0
- package/app/components/article/ArticleGrid.vue +125 -149
- package/app/components/article/ArticleHeaderBody.vue +20 -20
- package/app/components/article/ArticleHeadlineMeta.vue +26 -26
- package/app/components/article/ArticleList.vue +80 -95
- package/app/components/article/ArticlePage.vue +15 -14
- package/app/components/footer/FooterColumnHeading.vue +5 -5
- package/app/components/footer/FooterCopyright.vue +29 -29
- package/app/components/traits/Authors.vue +19 -20
- package/app/components/traits/BackButton.vue +15 -26
- package/app/components/traits/Category.vue +9 -9
- package/app/components/traits/CopyButton.vue +32 -39
- package/app/components/traits/Dates.vue +20 -20
- package/app/components/traits/Links.vue +17 -17
- package/app/components/traits/Location.vue +20 -20
- package/app/components/traits/Separator.vue +21 -26
- package/app/components/traits/SeparatorButtons.vue +53 -56
- package/app/components/traits/Surround.vue +48 -60
- package/app/components/traits/Toc.vue +16 -16
- package/app/composables/useArticleList.ts +24 -26
- package/app/composables/useArticleListQuery.ts +54 -0
- package/app/composables/useCategoryBadge.ts +27 -27
- package/app/composables/useClipboard.ts +26 -26
- package/app/composables/usePageContent.ts +18 -18
- package/app/composables/usePageSeo.ts +30 -30
- package/app/layouts/article.vue +117 -125
- package/app/layouts/content.vue +57 -65
- package/app/layouts/default.vue +3 -12
- package/app/types/config.ts +13 -6
- package/content.config.ts +6 -6
- package/nuxt.config.ts +80 -80
- package/package.json +3 -3
- package/schemas/collections.ts +46 -46
- package/schemas/index.ts +2 -2
- 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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
<
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
5
|
-
to?: RouteLocationRaw
|
|
6
|
-
icon?: string
|
|
7
|
-
label?: string
|
|
8
|
-
}>()
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
</
|
|
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 {
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
icon
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
<
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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
|
|
2
|
-
import type { PageCollections } from '@nuxt/content'
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
|
|
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>
|