Skip to content

Commit ac962a9

Browse files
committed
docs: add blog & changelog on search
1 parent b5b1e54 commit ac962a9

File tree

7 files changed

+46
-14
lines changed

7 files changed

+46
-14
lines changed

docs/app/app.vue

+17-4
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,24 @@ const heroBackgroundClass = computed(() => route.meta?.heroBackground || '')
1616
const appear = ref(false)
1717
const appeared = ref(false)
1818
19-
const { data: navigation } = await useAsyncData('navigation', () => queryCollectionNavigation('docs'), {
20-
transform: data => data.find(item => item.path === '/docs')?.children || []
19+
const { data: navigation } = await useAsyncData('navigation', () => {
20+
return Promise.all([
21+
queryCollectionNavigation('docs'),
22+
queryCollectionNavigation('blog'),
23+
queryCollectionNavigation('changelog')
24+
])
25+
}, {
26+
transform: data => data.flat()
2127
})
22-
const { data: files } = useLazyAsyncData('search', () => queryCollectionSearchSections('docs'), {
23-
server: false
28+
const { data: files } = useLazyAsyncData('search', () => {
29+
return Promise.all([
30+
queryCollectionSearchSections('docs'),
31+
queryCollectionSearchSections('blog'),
32+
queryCollectionSearchSections('changelog')
33+
])
34+
}, {
35+
server: false,
36+
transform: data => data.flat()
2437
})
2538
2639
useHead({

docs/app/components/AppHeader.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const navLinks = computed(() => links.value.map((link) => {
3535
icon: link.icon,
3636
title: link.label,
3737
path: link.to,
38-
children: navigation.value
38+
children: navigation.value.find(item => item.path === '/docs')?.children || []
3939
}
4040
}
4141
return {

docs/app/error.vue

+21-6
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,26 @@ useHead({
1818
}
1919
})
2020
21-
const { data: navigation } = await useAsyncData('navigation', () => queryCollectionNavigation('docs'), {
22-
transform: data => data.find(item => item.path === '/docs')?.children || []
21+
const { data: navigation } = await useAsyncData('navigation', () => {
22+
return Promise.all([
23+
queryCollectionNavigation('docs'),
24+
queryCollectionNavigation('blog'),
25+
queryCollectionNavigation('changelog')
26+
])
27+
}, {
28+
transform: data => data.flat()
2329
})
24-
const { data: files } = useLazyAsyncData('search', () => queryCollectionSearchSections('docs'), {
25-
server: false
30+
provide('navigation', navigation)
31+
32+
const { data: files } = useLazyAsyncData('search', () => {
33+
return Promise.all([
34+
queryCollectionSearchSections('docs'),
35+
queryCollectionSearchSections('blog'),
36+
queryCollectionSearchSections('changelog')
37+
])
38+
}, {
39+
server: false,
40+
transform: data => data.flat()
2641
})
2742
2843
const links = computed(() => [
@@ -57,10 +72,10 @@ const links = computed(() => [
5772

5873
<template>
5974
<UApp>
60-
<!-- <AppHeader /> -->
75+
<AppHeader />
6176
<UError :error="error" />
6277

63-
<!-- <AppFooter /> -->
78+
<AppFooter />
6479

6580
<ClientOnly>
6681
<LazyUContentSearch :files="files" :navigation="navigation" :links="links" />

docs/app/layouts/docs.vue

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22
import type { ContentNavigationItem } from '@nuxt/content'
33
44
const navigation = inject<Ref<ContentNavigationItem[]>>('navigation')
5+
6+
const asideNavigation = computed(() => navigation.value.find(item => item.path === '/docs')?.children || [])
57
</script>
68

79
<template>
810
<UContainer>
911
<UPage>
1012
<template #left>
1113
<UPageAside>
12-
<UContentNavigation :navigation="navigation" highlight />
14+
<UContentNavigation :navigation="asideNavigation" highlight />
1315
</UPageAside>
1416
</template>
1517
<slot />

docs/content.config.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export default defineContentConfig({
108108
}),
109109
changelog: defineCollection({
110110
type: 'page',
111-
source: 'changelog/*.md',
111+
source: 'changelog/**/*',
112112
schema: z.object({
113113
image: z.string().editor({ input: 'media' }),
114114
authors: z.array(Author),
@@ -117,7 +117,7 @@ export default defineContentConfig({
117117
}),
118118
blog: defineCollection({
119119
type: 'page',
120-
source: 'blog/**/*.md',
120+
source: 'blog/**/*',
121121
schema: z.object({
122122
image: z.string().editor({ input: 'media' }),
123123
authors: z.array(Author),

docs/content/blog/.navigation.yml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
icon: i-lucide-newspaper
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
icon: i-lucide-megaphone

0 commit comments

Comments
 (0)