Skip to content

Commit

Permalink
docs(app): update error
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamincanac committed Nov 27, 2024
1 parent a2512f6 commit 6eb0bbb
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 12 deletions.
14 changes: 5 additions & 9 deletions docs/app/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,6 @@ useServerSeoMeta({
const { framework, frameworks } = useSharedData()
const groups = computed(() => {
return [{
id: 'framework',
label: 'Framework',
items: frameworks.value
}]
})
function filterFrameworkItems(items: any[]) {
return items?.filter(item => !item.framework || item.framework === framework.value)
}
Expand Down Expand Up @@ -131,7 +123,11 @@ provide('navigation', filteredNavigation)
<LazyUContentSearch
v-model:search-term="searchTerm"
:files="files"
:groups="groups"
:groups="[{
id: 'framework',
label: 'Framework',
items: frameworks
}]"
:navigation="filteredNavigation"
:fuse="{ resultLimit: 42 }"
/>
Expand Down
55 changes: 52 additions & 3 deletions docs/app/error.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script setup lang="ts">
import colors from 'tailwindcss/colors'
// import { debounce } from 'perfect-debounce'
import type { NuxtError } from '#app'
const props = defineProps<{
Expand All @@ -11,7 +12,19 @@ const appConfig = useAppConfig()
const colorMode = useColorMode()
const { data: navigation } = await useAsyncData('navigation', () => queryCollectionNavigation('content'))
const { data: files } = await useAsyncData('files', () => queryCollectionSearchSections('content', { ignoredTags: ['style'] }))
const { data: files } = useLazyAsyncData('search', () => queryCollectionSearchSections('content'), {
server: false
})
const searchTerm = ref('')
// watch(searchTerm, debounce((query: string) => {
// if (!query) {
// return
// }
// useTrackEvent('Search', { props: { query: `${query} - ${searchTerm.value?.commandPaletteRef.results.length} results` } })
// }, 500))
const links = computed(() => [{
label: 'Docs',
Expand Down Expand Up @@ -68,7 +81,33 @@ useServerSeoMeta({
twitterCard: 'summary_large_image'
})
provide('navigation', navigation)
const { framework, frameworks } = useSharedData()
function filterFrameworkItems(items: any[]) {
return items?.filter(item => !item.framework || item.framework === framework.value)
}
function processNavigationItem(item: any): any {
if (item.shadow) {
const matchingChild = filterFrameworkItems(item.children)?.[0]
return matchingChild
? {
...matchingChild,
title: item.title,
children: matchingChild.children ? processNavigationItem(matchingChild) : undefined
}
: item
}
return {
...item,
children: item.children?.length ? filterFrameworkItems(item.children)?.map(processNavigationItem) : undefined
}
}
const filteredNavigation = computed(() => navigation.value?.map(processNavigationItem))
provide('navigation', filteredNavigation)
</script>

<template>
Expand All @@ -84,7 +123,17 @@ provide('navigation', navigation)
<Footer />

<ClientOnly>
<LazyUContentSearch :files="files" :navigation="navigation" :fuse="{ resultLimit: 42 }" />
<LazyUContentSearch
v-model:search-term="searchTerm"
:files="files"
:groups="[{
id: 'framework',
label: 'Framework',
items: frameworks
}]"
:navigation="filteredNavigation"
:fuse="{ resultLimit: 42 }"
/>
</ClientOnly>
</UApp>
</template>

0 comments on commit 6eb0bbb

Please sign in to comment.