@happydesigns/ui 0.16.0 → 0.17.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 +64 -53
- package/app/app.config.ts +138 -165
- package/app/app.vue +0 -2
- package/app/assets/css/styles.css +38 -0
- package/app/components/Carousel.vue +33 -0
- package/app/components/{content/Snippet.vue → Snippet.vue} +6 -2
- package/app/components/article/ArticleGridDate.vue +19 -16
- package/app/components/article/ArticleHeaderBody.vue +26 -20
- package/app/components/article/ArticleHeadlineMeta.vue +37 -26
- package/app/components/article/ArticleList.vue +1 -1
- package/app/components/article/ArticlePage.vue +1 -1
- package/app/components/footer/FooterColumns.vue +60 -101
- package/app/components/search/ContentSearch.client.vue +59 -0
- package/app/components/studio/StudioLoginButton.client.vue +11 -3
- package/app/components/traits/Category.vue +1 -1
- package/app/components/traits/CopyButton.vue +40 -32
- package/app/components/traits/Links.vue +21 -17
- package/app/components/traits/Surround.vue +5 -6
- package/app/components/traits/Toc.vue +18 -16
- package/app/composables/useArticleList.ts +29 -27
- package/app/composables/useClipboard.ts +48 -26
- package/app/composables/useContentSearchData.ts +42 -0
- package/app/composables/useNavigationLinks.ts +40 -0
- package/app/composables/usePageContent.ts +1 -3
- package/app/composables/usePageSeo.ts +7 -15
- package/app/internal/pageLayout.ts +7 -0
- package/app/layouts/article.vue +137 -120
- package/app/layouts/content.vue +63 -59
- package/app/types/config.ts +91 -13
- package/app/utils/createContentSearchLoader.ts +45 -0
- package/app/utils/formatDate.ts +1 -1
- package/app/utils/formatDateTime.ts +1 -1
- package/app/utils/isNavigationTargetActive.ts +12 -0
- package/app/utils/resolveUsers.ts +56 -42
- package/nuxt.config.ts +1 -13
- package/package.json +17 -9
- package/schemas/collections.ts +4 -0
- package/schemas/indexes.ts +10 -0
- package/server/api/navigation.json.get.ts +11 -0
- package/server/api/search.json.get.ts +11 -0
- package/server/utils/contentSearch.ts +67 -0
- package/shared/types/app-config.d.ts +23 -0
- package/app/assets/css/main.css +0 -14
- package/app/components/content/Carousel.vue +0 -11
|
@@ -1,26 +1,48 @@
|
|
|
1
|
-
import type { ToastProps } from '#ui/types'
|
|
2
|
-
import { useClipboard as _useClipboard } from '@vueuse/core'
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
1
|
+
import type { ToastProps } from '#ui/types'
|
|
2
|
+
import { useClipboard as _useClipboard } from '@vueuse/core'
|
|
3
|
+
|
|
4
|
+
type ClipboardToast = Partial<ToastProps> & { id?: string | number }
|
|
5
|
+
|
|
6
|
+
export type ClipboardCopyOptions = ClipboardToast & {
|
|
7
|
+
error?: ClipboardToast
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function useClipboard() {
|
|
11
|
+
const { copy: copyToClipboard, copied } = _useClipboard()
|
|
12
|
+
const toast = useToast()
|
|
13
|
+
|
|
14
|
+
function upsertToast(options: ClipboardToast) {
|
|
15
|
+
const { id, ...toastOptions } = options
|
|
16
|
+
|
|
17
|
+
if (id !== undefined && toast.toasts.value.some(toastItem => toastItem.id === id)) {
|
|
18
|
+
toast.update(id, toastOptions)
|
|
19
|
+
return
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
toast.add(id === undefined ? toastOptions : { ...toastOptions, id })
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const copy = async (source: string, options?: ClipboardCopyOptions): Promise<boolean> => {
|
|
26
|
+
const { error: errorToast, ...successToast } = options ?? {}
|
|
27
|
+
|
|
28
|
+
try {
|
|
29
|
+
await copyToClipboard(source)
|
|
30
|
+
|
|
31
|
+
if (Object.keys(successToast).length > 0)
|
|
32
|
+
upsertToast(successToast)
|
|
33
|
+
|
|
34
|
+
return true
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
if (errorToast)
|
|
38
|
+
upsertToast(errorToast)
|
|
39
|
+
|
|
40
|
+
return false
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
copy,
|
|
46
|
+
copied,
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +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
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { FooterColumn, FooterColumnLink, NavigationMenuItem } from '@nuxt/ui'
|
|
2
|
+
import { createSharedComposable } from '@vueuse/core'
|
|
3
|
+
|
|
4
|
+
function withActiveState<T extends { to?: unknown, children?: T[] }>(items: T[], currentPath: string): T[] {
|
|
5
|
+
return items.map((item) => {
|
|
6
|
+
const children = item.children ? withActiveState(item.children, currentPath) : undefined
|
|
7
|
+
|
|
8
|
+
return {
|
|
9
|
+
...item,
|
|
10
|
+
...(children ? { children } : {}),
|
|
11
|
+
active: isNavigationTargetActive(currentPath, item.to)
|
|
12
|
+
|| Boolean(children?.some(child => 'active' in child && child.active)),
|
|
13
|
+
}
|
|
14
|
+
})
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function _useHeaderLinks() {
|
|
18
|
+
const appConfig = useAppConfig()
|
|
19
|
+
const route = useRoute()
|
|
20
|
+
const headerLinks = computed(() => withActiveState(
|
|
21
|
+
(appConfig.app.links.header ?? []) as NavigationMenuItem[],
|
|
22
|
+
route.path,
|
|
23
|
+
))
|
|
24
|
+
|
|
25
|
+
return { headerLinks }
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function _useFooterLinks() {
|
|
29
|
+
const appConfig = useAppConfig()
|
|
30
|
+
const route = useRoute()
|
|
31
|
+
const footerLinks = computed(() => ((appConfig.app.links.footer ?? []) as FooterColumn[]).map(column => ({
|
|
32
|
+
...column,
|
|
33
|
+
children: withActiveState((column.children ?? []) as FooterColumnLink[], route.path),
|
|
34
|
+
})))
|
|
35
|
+
|
|
36
|
+
return { footerLinks }
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export const useHeaderLinks = import.meta.client ? createSharedComposable(_useHeaderLinks) : _useHeaderLinks
|
|
40
|
+
export const useFooterLinks = import.meta.client ? createSharedComposable(_useFooterLinks) : _useFooterLinks
|
|
@@ -25,7 +25,5 @@ export function usePageContent<C extends keyof PageCollections = 'page', B = obj
|
|
|
25
25
|
|
|
26
26
|
const handler = () => queryCollection(resolvedCollection.value as keyof PageCollections).path(resolvedPath.value).first()
|
|
27
27
|
|
|
28
|
-
return useAsyncData(key, handler,
|
|
29
|
-
watch: [resolvedPath, resolvedCollection],
|
|
30
|
-
}) as unknown as AsyncData<(PageCollections[C] & B) | null, Error | null>
|
|
28
|
+
return useAsyncData(key, handler) as unknown as AsyncData<(PageCollections[C] & B) | null, Error | null>
|
|
31
29
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { watchEffect } from 'vue'
|
|
2
|
-
|
|
3
1
|
interface SeoRelevantPageData {
|
|
4
2
|
seo?: {
|
|
5
3
|
title?: string
|
|
@@ -12,19 +10,13 @@ interface SeoRelevantPageData {
|
|
|
12
10
|
}
|
|
13
11
|
|
|
14
12
|
export function usePageSeo(page: Ref<SeoRelevantPageData | null | undefined>) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const title = page.value.seo?.title || page.value.title
|
|
18
|
-
const description = page.value.seo?.description || page.value.description
|
|
19
|
-
const ogTitle = page.value.seo?.ogTitle || title
|
|
20
|
-
const ogDescription = page.value.seo?.ogDescription || description
|
|
13
|
+
const title = () => page.value?.seo?.title || page.value?.title
|
|
14
|
+
const description = () => page.value?.seo?.description || page.value?.description
|
|
21
15
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
})
|
|
28
|
-
}
|
|
16
|
+
useSeoMeta({
|
|
17
|
+
title,
|
|
18
|
+
ogTitle: () => page.value?.seo?.ogTitle || title(),
|
|
19
|
+
description,
|
|
20
|
+
ogDescription: () => page.value?.seo?.ogDescription || description(),
|
|
29
21
|
})
|
|
30
22
|
}
|
package/app/layouts/article.vue
CHANGED
|
@@ -1,120 +1,137 @@
|
|
|
1
|
-
<script setup lang="ts" generic="C extends keyof PageCollections = 'article'">
|
|
2
|
-
import type { PageCollections } from '@nuxt/content'
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
:
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
1
|
+
<script setup lang="ts" generic="C extends keyof PageCollections = 'article'">
|
|
2
|
+
import type { PageCollections } from '@nuxt/content'
|
|
3
|
+
import type { BreadcrumbItem } from '@nuxt/ui'
|
|
4
|
+
import { getPageLayoutUi } from '../internal/pageLayout'
|
|
5
|
+
|
|
6
|
+
const props = defineProps<{
|
|
7
|
+
path?: string
|
|
8
|
+
collection?: C
|
|
9
|
+
}>()
|
|
10
|
+
|
|
11
|
+
const route = useRoute()
|
|
12
|
+
const collection = computed(() => props.collection ?? 'article')
|
|
13
|
+
|
|
14
|
+
const { data: page } = await usePageContent({
|
|
15
|
+
path: () => props.path,
|
|
16
|
+
collection: () => collection.value,
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
const { config, has } = useVariant(collection)
|
|
20
|
+
const hasHeader = has('header')
|
|
21
|
+
const hasBackButton = has('backButton')
|
|
22
|
+
const hasCopyButton = has('copyButton')
|
|
23
|
+
const hasSeparator = has('separator')
|
|
24
|
+
const hasSurround = has('surround')
|
|
25
|
+
const hasToc = has('toc')
|
|
26
|
+
const tocEnabled = computed(() => !page.value || !('toc' in page.value) || page.value.toc !== false)
|
|
27
|
+
const renderToc = computed(() => hasToc.value
|
|
28
|
+
&& tocEnabled.value
|
|
29
|
+
&& Boolean(page.value?.body?.toc?.links?.length))
|
|
30
|
+
const pageUi = computed(() => getPageLayoutUi(renderToc.value))
|
|
31
|
+
|
|
32
|
+
if (!page.value) {
|
|
33
|
+
throw createError({
|
|
34
|
+
statusCode: 404,
|
|
35
|
+
statusMessage: `${collection.value} ${props.path || route.path} not found`,
|
|
36
|
+
fatal: true,
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
usePageSeo(page)
|
|
41
|
+
|
|
42
|
+
const header = computed(() => resolvePageHeader(page.value))
|
|
43
|
+
|
|
44
|
+
const breadcrumbsBase = computed(() => (config.value.breadcrumbs ?? []) as BreadcrumbItem[])
|
|
45
|
+
|
|
46
|
+
const breadcrumbItems = computed(() => {
|
|
47
|
+
const baseItems = breadcrumbsBase.value.map((item, index) => ({
|
|
48
|
+
...item,
|
|
49
|
+
...(index === breadcrumbsBase.value.length - 1
|
|
50
|
+
? { ui: { ...item.ui, separator: 'hidden sm:flex' } }
|
|
51
|
+
: {}),
|
|
52
|
+
}))
|
|
53
|
+
|
|
54
|
+
return [
|
|
55
|
+
...baseItems,
|
|
56
|
+
{
|
|
57
|
+
label: page.value?.title,
|
|
58
|
+
to: page.value?.path,
|
|
59
|
+
ui: { item: 'hidden sm:flex' },
|
|
60
|
+
},
|
|
61
|
+
]
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
const backLink = computed(() => {
|
|
65
|
+
const lastBreadcrumb = breadcrumbsBase.value.at(-1)
|
|
66
|
+
|
|
67
|
+
if (!lastBreadcrumb && !config.value?.backButton)
|
|
68
|
+
return null
|
|
69
|
+
|
|
70
|
+
return { ...(lastBreadcrumb ?? {}), ...config.value?.backButton }
|
|
71
|
+
})
|
|
72
|
+
</script>
|
|
73
|
+
|
|
74
|
+
<template>
|
|
75
|
+
<UContainer v-if="page">
|
|
76
|
+
<UPageHeader
|
|
77
|
+
v-if="hasHeader && header"
|
|
78
|
+
v-bind="header"
|
|
79
|
+
:ui="{
|
|
80
|
+
headline: 'all:flex flex-col gap-y-8 items-start',
|
|
81
|
+
wrapper: 'lg:flex-row',
|
|
82
|
+
}"
|
|
83
|
+
>
|
|
84
|
+
<template #headline>
|
|
85
|
+
<UBreadcrumb
|
|
86
|
+
:ui="{ root: 'max-w-full' }"
|
|
87
|
+
:items="breadcrumbItems"
|
|
88
|
+
/>
|
|
89
|
+
<HArticleHeadlineMeta :page="page" :collection="collection" />
|
|
90
|
+
</template>
|
|
91
|
+
<HArticleHeaderBody :page="page" :collection="collection">
|
|
92
|
+
<slot name="header" />
|
|
93
|
+
</HArticleHeaderBody>
|
|
94
|
+
</UPageHeader>
|
|
95
|
+
|
|
96
|
+
<UPage :ui="pageUi">
|
|
97
|
+
<UPageBody>
|
|
98
|
+
<slot />
|
|
99
|
+
|
|
100
|
+
<div
|
|
101
|
+
v-if="hasBackButton || hasCopyButton"
|
|
102
|
+
class="all:flex items-center justify-between mt-12"
|
|
103
|
+
>
|
|
104
|
+
<HBackButton
|
|
105
|
+
v-if="hasBackButton && backLink"
|
|
106
|
+
v-bind="backLink"
|
|
107
|
+
/>
|
|
108
|
+
<div class="all:flex justify-end items-center gap-1.5 ml-auto">
|
|
109
|
+
<HCopyButton v-if="hasCopyButton" v-bind="config.copyButton" />
|
|
110
|
+
</div>
|
|
111
|
+
</div>
|
|
112
|
+
|
|
113
|
+
<HSeparator
|
|
114
|
+
v-if="hasSeparator"
|
|
115
|
+
:stem="page?.stem"
|
|
116
|
+
:extension="page?.extension"
|
|
117
|
+
v-bind="config.separator"
|
|
118
|
+
/>
|
|
119
|
+
|
|
120
|
+
<HSurround
|
|
121
|
+
v-if="hasSurround"
|
|
122
|
+
:collection="collection"
|
|
123
|
+
v-bind="config.surround"
|
|
124
|
+
:query="config.query"
|
|
125
|
+
/>
|
|
126
|
+
</UPageBody>
|
|
127
|
+
|
|
128
|
+
<template #right>
|
|
129
|
+
<HToc
|
|
130
|
+
v-if="renderToc"
|
|
131
|
+
:links="page?.body?.toc?.links"
|
|
132
|
+
:title="page?.body?.toc?.title"
|
|
133
|
+
/>
|
|
134
|
+
</template>
|
|
135
|
+
</UPage>
|
|
136
|
+
</UContainer>
|
|
137
|
+
</template>
|
package/app/layouts/content.vue
CHANGED
|
@@ -1,59 +1,63 @@
|
|
|
1
|
-
<script setup lang="ts" generic="C extends 'page' = 'page'">
|
|
2
|
-
import type { Collections } from '@nuxt/content'
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
<
|
|
51
|
-
<
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
1
|
+
<script setup lang="ts" generic="C extends 'page' = 'page'">
|
|
2
|
+
import type { Collections } from '@nuxt/content'
|
|
3
|
+
import { getPageLayoutUi } from '../internal/pageLayout'
|
|
4
|
+
|
|
5
|
+
const {
|
|
6
|
+
path,
|
|
7
|
+
collection = 'page' as C,
|
|
8
|
+
} = defineProps<{
|
|
9
|
+
path?: string
|
|
10
|
+
collection?: C
|
|
11
|
+
}>()
|
|
12
|
+
|
|
13
|
+
const appConfig = useAppConfig()
|
|
14
|
+
const route = useRoute()
|
|
15
|
+
|
|
16
|
+
const { data: page } = await usePageContent<C, Collections['page']>({
|
|
17
|
+
path: () => path,
|
|
18
|
+
collection: () => collection,
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
const { has } = useVariant(collection)
|
|
22
|
+
const hasHeader = has('header')
|
|
23
|
+
const hasToc = has('toc')
|
|
24
|
+
|
|
25
|
+
if (!page.value) {
|
|
26
|
+
throw createError({
|
|
27
|
+
statusCode: 404,
|
|
28
|
+
statusMessage: `${collection} ${path || route.path} not found`,
|
|
29
|
+
fatal: true,
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
usePageSeo(page)
|
|
34
|
+
|
|
35
|
+
const renderToc = computed(() => hasToc.value
|
|
36
|
+
&& page.value?.toc !== false
|
|
37
|
+
&& Boolean(page.value?.body?.toc?.links?.length))
|
|
38
|
+
const pageUi = computed(() => getPageLayoutUi(renderToc.value))
|
|
39
|
+
const header = computed(() => resolvePageHeader(page.value))
|
|
40
|
+
</script>
|
|
41
|
+
|
|
42
|
+
<template>
|
|
43
|
+
<UContainer v-if="page">
|
|
44
|
+
<UPageHeader
|
|
45
|
+
v-if="hasHeader && header"
|
|
46
|
+
v-bind="header"
|
|
47
|
+
/>
|
|
48
|
+
|
|
49
|
+
<UPage :ui="pageUi">
|
|
50
|
+
<UPageBody>
|
|
51
|
+
<slot />
|
|
52
|
+
</UPageBody>
|
|
53
|
+
|
|
54
|
+
<template #right>
|
|
55
|
+
<UContentToc
|
|
56
|
+
v-if="renderToc"
|
|
57
|
+
:links="page.body?.toc?.links"
|
|
58
|
+
:title="page.body?.toc?.title || appConfig.app.toc?.title"
|
|
59
|
+
/>
|
|
60
|
+
</template>
|
|
61
|
+
</UPage>
|
|
62
|
+
</UContainer>
|
|
63
|
+
</template>
|