@@ -10,20 +10,16 @@ const route = useRoute()
10
10
const { toc, seo } = useAppConfig ()
11
11
const navigation = inject <Ref <ContentNavigationItem []>>(' navigation' )
12
12
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 ) {
22
15
throw createError ({ statusCode: 404 , statusMessage: ' Page not found' , fatal: true })
23
16
}
24
17
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
+ })
27
23
28
24
useSeoMeta ({
29
25
title: page .value .seo .title ,
@@ -34,14 +30,21 @@ useSeoMeta({
34
30
35
31
defineOgImageComponent (' Docs' )
36
32
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
+ }
38
45
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
+ })
45
48
</script >
46
49
47
50
<template >
0 commit comments