Skip to content

Commit 6eb0bbb

Browse files
committed
docs(app): update error
1 parent a2512f6 commit 6eb0bbb

File tree

2 files changed

+57
-12
lines changed

2 files changed

+57
-12
lines changed

docs/app/app.vue

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,6 @@ useServerSeoMeta({
7575
7676
const { framework, frameworks } = useSharedData()
7777
78-
const groups = computed(() => {
79-
return [{
80-
id: 'framework',
81-
label: 'Framework',
82-
items: frameworks.value
83-
}]
84-
})
85-
8678
function filterFrameworkItems(items: any[]) {
8779
return items?.filter(item => !item.framework || item.framework === framework.value)
8880
}
@@ -131,7 +123,11 @@ provide('navigation', filteredNavigation)
131123
<LazyUContentSearch
132124
v-model:search-term="searchTerm"
133125
:files="files"
134-
:groups="groups"
126+
:groups="[{
127+
id: 'framework',
128+
label: 'Framework',
129+
items: frameworks
130+
}]"
135131
:navigation="filteredNavigation"
136132
:fuse="{ resultLimit: 42 }"
137133
/>

docs/app/error.vue

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script setup lang="ts">
22
import colors from 'tailwindcss/colors'
3+
// import { debounce } from 'perfect-debounce'
34
import type { NuxtError } from '#app'
45
56
const props = defineProps<{
@@ -11,7 +12,19 @@ const appConfig = useAppConfig()
1112
const colorMode = useColorMode()
1213
1314
const { data: navigation } = await useAsyncData('navigation', () => queryCollectionNavigation('content'))
14-
const { data: files } = await useAsyncData('files', () => queryCollectionSearchSections('content', { ignoredTags: ['style'] }))
15+
const { data: files } = useLazyAsyncData('search', () => queryCollectionSearchSections('content'), {
16+
server: false
17+
})
18+
19+
const searchTerm = ref('')
20+
21+
// watch(searchTerm, debounce((query: string) => {
22+
// if (!query) {
23+
// return
24+
// }
25+
26+
// useTrackEvent('Search', { props: { query: `${query} - ${searchTerm.value?.commandPaletteRef.results.length} results` } })
27+
// }, 500))
1528
1629
const links = computed(() => [{
1730
label: 'Docs',
@@ -68,7 +81,33 @@ useServerSeoMeta({
6881
twitterCard: 'summary_large_image'
6982
})
7083
71-
provide('navigation', navigation)
84+
const { framework, frameworks } = useSharedData()
85+
86+
function filterFrameworkItems(items: any[]) {
87+
return items?.filter(item => !item.framework || item.framework === framework.value)
88+
}
89+
90+
function processNavigationItem(item: any): any {
91+
if (item.shadow) {
92+
const matchingChild = filterFrameworkItems(item.children)?.[0]
93+
return matchingChild
94+
? {
95+
...matchingChild,
96+
title: item.title,
97+
children: matchingChild.children ? processNavigationItem(matchingChild) : undefined
98+
}
99+
: item
100+
}
101+
102+
return {
103+
...item,
104+
children: item.children?.length ? filterFrameworkItems(item.children)?.map(processNavigationItem) : undefined
105+
}
106+
}
107+
108+
const filteredNavigation = computed(() => navigation.value?.map(processNavigationItem))
109+
110+
provide('navigation', filteredNavigation)
72111
</script>
73112

74113
<template>
@@ -84,7 +123,17 @@ provide('navigation', navigation)
84123
<Footer />
85124

86125
<ClientOnly>
87-
<LazyUContentSearch :files="files" :navigation="navigation" :fuse="{ resultLimit: 42 }" />
126+
<LazyUContentSearch
127+
v-model:search-term="searchTerm"
128+
:files="files"
129+
:groups="[{
130+
id: 'framework',
131+
label: 'Framework',
132+
items: frameworks
133+
}]"
134+
:navigation="filteredNavigation"
135+
:fuse="{ resultLimit: 42 }"
136+
/>
88137
</ClientOnly>
89138
</UApp>
90139
</template>

0 commit comments

Comments
 (0)