File tree Expand file tree Collapse file tree 1 file changed +30
-5
lines changed Expand file tree Collapse file tree 1 file changed +30
-5
lines changed Original file line number Diff line number Diff line change @@ -15,12 +15,28 @@ interface Template {
15
15
slug: string
16
16
}
17
17
18
- const { data : templates } = await useFetch <Template []>(' /api/templates.json' )
18
+ const { data } = await useFetch <Template []>(' /api/templates.json' )
19
19
const route = useRoute ()
20
20
const { data : page } = await useAsyncData (route .path , () => {
21
21
return queryCollection (' templates' ).first ()
22
22
})
23
23
24
+ const { data : featurePaths } = await useAsyncData (' featurePaths' , () =>
25
+ queryCollection (' docs' ).where (' path' , ' LIKE' , ' /docs/features/%' ).select (' path' ).all ()
26
+ )
27
+
28
+ const templates = computed (() => {
29
+ if (! data .value ) return []
30
+
31
+ return data .value .map (template => ({
32
+ ... template ,
33
+ features: template .features .map (feature => ({
34
+ name: feature ,
35
+ hasPage: featurePaths .value ?.some (item => item .path === ` /docs/features/${feature } ` ) || false
36
+ }))
37
+ }))
38
+ })
39
+
24
40
useSeoMeta ({
25
41
title: page .value .title ,
26
42
ogTitle: ` ${page .value .title } · NuxtHub ` ,
@@ -85,14 +101,23 @@ defineOgImageComponent('Docs')
85
101
size =" sm"
86
102
class =" rounded-full"
87
103
/>
88
- <NuxtLink v-for =" feature of template.features" :key =" feature" :to =" `/docs/features/${feature}`" >
104
+ <template v-for =" feature of template .features " :key =" feature .name " >
105
+ <NuxtLink v-if =" feature.hasPage" :to =" `/docs/features/${feature.name}`" >
106
+ <UBadge
107
+ :label =" feature.name"
108
+ color =" neutral"
109
+ variant =" subtle"
110
+ class =" rounded-full hover:text-black dark:hover:text-white"
111
+ />
112
+ </NuxtLink >
89
113
<UBadge
90
- :label =" feature"
114
+ v-else
115
+ :label =" feature.name"
91
116
color =" neutral"
92
117
variant =" subtle"
93
- class =" rounded-full hover:text-black dark:hover:text-white "
118
+ class =" rounded-full"
94
119
/>
95
- </NuxtLink >
120
+ </template >
96
121
</div >
97
122
</template >
98
123
<template #footer >
You can’t perform that action at this time.
0 commit comments