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 {
1515 slug: string
1616}
1717
18- const { data : templates } = await useFetch <Template []>(' /api/templates.json' )
18+ const { data } = await useFetch <Template []>(' /api/templates.json' )
1919const route = useRoute ()
2020const { data : page } = await useAsyncData (route .path , () => {
2121 return queryCollection (' templates' ).first ()
2222})
2323
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+
2440useSeoMeta ({
2541 title: page .value .title ,
2642 ogTitle: ` ${page .value .title } · NuxtHub ` ,
@@ -85,14 +101,23 @@ defineOgImageComponent('Docs')
85101 size =" sm"
86102 class =" rounded-full"
87103 />
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 >
89113 <UBadge
90- :label =" feature"
114+ v-else
115+ :label =" feature.name"
91116 color =" neutral"
92117 variant =" subtle"
93- class =" rounded-full hover:text-black dark:hover:text-white "
118+ class =" rounded-full"
94119 />
95- </NuxtLink >
120+ </template >
96121 </div >
97122 </template >
98123 <template #footer >
You can’t perform that action at this time.
0 commit comments