undocs 0.3.8 → 0.3.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -150,17 +150,14 @@ function removeFirstH1AndBlockquote(body: MarkdownRoot, content: ParsedContentFi
|
|
|
150
150
|
function inferIcons(content: ParsedContentFile) {
|
|
151
151
|
const icon = content.meta?.icon || content.navigation?.icon || content.body?.icon || _resolveIcon(content.path)
|
|
152
152
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}
|
|
153
|
+
content.body ??= {}
|
|
154
|
+
content.body.icon ??= icon
|
|
156
155
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}
|
|
156
|
+
content.meta ??= {}
|
|
157
|
+
content.meta.icon ??= icon
|
|
160
158
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}
|
|
159
|
+
content.navigation ??= {}
|
|
160
|
+
content.navigation.icon ??= icon
|
|
164
161
|
}
|
|
165
162
|
|
|
166
163
|
function _resolveIcon(path: string = '') {
|
package/app/pages/[...slug].vue
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { kebabCase } from 'scule'
|
|
3
|
-
import {
|
|
3
|
+
import type { ContentNavigationItem } from '@nuxt/content'
|
|
4
4
|
|
|
5
5
|
definePageMeta({
|
|
6
6
|
layout: 'docs',
|
|
@@ -27,6 +27,30 @@ const { data: surround } = await useAsyncData(`${kebabCase(route.path)}-surround
|
|
|
27
27
|
})
|
|
28
28
|
})
|
|
29
29
|
|
|
30
|
+
const navigation = inject<Ref<ContentNavigationItem[]>>('navigation')
|
|
31
|
+
|
|
32
|
+
// console.log(JSON.stringify(navigation?.value, null, 2))
|
|
33
|
+
|
|
34
|
+
function makeBreadcrumb(items: ContentNavigationItem[], path: string, level = 0) {
|
|
35
|
+
const parent = [...items].find((i) => path.startsWith(i.path) && i.children?.length > 0)
|
|
36
|
+
if (!parent) {
|
|
37
|
+
return []
|
|
38
|
+
}
|
|
39
|
+
if (level === 0) {
|
|
40
|
+
return makeBreadcrumb(parent.children, path, level + 1)
|
|
41
|
+
}
|
|
42
|
+
return [
|
|
43
|
+
{
|
|
44
|
+
label: parent.title,
|
|
45
|
+
icon: parent.icon as string,
|
|
46
|
+
to: parent.page !== false ? parent.path : '',
|
|
47
|
+
},
|
|
48
|
+
...makeBreadcrumb(parent.children, path, level + 1),
|
|
49
|
+
]
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const breadcrumb = computed(() => makeBreadcrumb(navigation?.value || [], page.value.path))
|
|
53
|
+
|
|
30
54
|
usePageSEO({
|
|
31
55
|
title: `${page.value?.title} - ${appConfig.site.name}`,
|
|
32
56
|
ogTitle: page.value?.title,
|
|
@@ -36,12 +60,11 @@ usePageSEO({
|
|
|
36
60
|
|
|
37
61
|
<template>
|
|
38
62
|
<UPage v-if="page">
|
|
39
|
-
<UPageHeader
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
/>
|
|
63
|
+
<UPageHeader :title="page.title" :description="page.description" :links="page.links">
|
|
64
|
+
<template #headline>
|
|
65
|
+
<UBreadcrumb :items="breadcrumb" />
|
|
66
|
+
</template>
|
|
67
|
+
</UPageHeader>
|
|
45
68
|
|
|
46
69
|
<template #right>
|
|
47
70
|
<UContentToc title="On this page" :links="page.body?.toc?.links || []" highlight />
|