Skip to content

Commit 7bb0080

Browse files
committed
chore(app): ts errors
1 parent a3f8da3 commit 7bb0080

File tree

1 file changed

+21
-18
lines changed

1 file changed

+21
-18
lines changed

app/pages/[...slug].vue

+21-18
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,16 @@ const route = useRoute()
1010
const { toc, seo } = useAppConfig()
1111
const navigation = inject<Ref<ContentNavigationItem[]>>('navigation')
1212
13-
const { data } = await useAsyncData(route.path, () => Promise.all([
14-
queryCollection('docs').path(route.path).first(),
15-
queryCollectionItemSurroundings('docs', route.path, {
16-
fields: ['title', 'description']
17-
})
18-
]), {
19-
transform: ([page, surround]) => ({ page, surround })
20-
})
21-
if (!data.value || !data.value.page) {
13+
const { data: page } = await useAsyncData(route.path, () => queryCollection('docs').path(route.path).first())
14+
if (!page.value) {
2215
throw createError({ statusCode: 404, statusMessage: 'Page not found', fatal: true })
2316
}
2417
25-
const page = computed(() => data.value?.page)
26-
const surround = computed(() => data.value?.surround)
18+
const { data: surround } = await useAsyncData(`${route.path}-surround`, () => {
19+
return queryCollectionItemSurroundings('docs', route.path, {
20+
fields: ['description']
21+
})
22+
})
2723
2824
useSeoMeta({
2925
title: page.value.seo.title,
@@ -34,14 +30,21 @@ useSeoMeta({
3430
3531
defineOgImageComponent('Docs')
3632
37-
const headline = computed(() => findPageHeadline(navigation.value, page.value))
33+
const headline = computed(() => findPageHeadline(navigation!.value, page.value))
34+
35+
const links = computed(() => {
36+
const links = []
37+
if (toc?.bottom?.edit) {
38+
links.push({
39+
icon: 'i-lucide-external-link',
40+
label: 'Edit this page',
41+
to: `${toc.bottom.edit}/${page?.value?.stem}.${page?.value?.extension}`,
42+
target: '_blank'
43+
})
44+
}
3845
39-
const links = computed(() => [toc?.bottom?.edit && {
40-
icon: 'i-lucide-external-link',
41-
label: 'Edit this page',
42-
to: `${toc.bottom.edit}/${page?.value?.stem}.${page?.value?.extension}`,
43-
target: '_blank'
44-
}, ...(toc?.bottom?.links || [])].filter(Boolean))
46+
return [...links, ...(toc?.bottom?.links || [])].filter(Boolean)
47+
})
4548
</script>
4649

4750
<template>

0 commit comments

Comments
 (0)