forked from nuxt-ui-pro/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.vue
76 lines (62 loc) · 1.53 KB
/
app.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<script setup lang="ts">
import type { ParsedContent } from '@nuxt/content/dist/runtime/types'
const { seo } = useAppConfig()
const route = useRoute()
const { data: navigation, refresh: refreshNavigation } = await useAsyncData('navigation', () => fetchContentNavigation(), {
transform: (data) => {
const result = []
data.forEach((item) => {
if (item.title.toLowerCase() === route.fullPath.split('/')[1]) {
if (item.children) {
item.children.forEach((child) => {
result.push(child)
})
}
}
})
return result
}
})
const { data: files } = useLazyFetch<ParsedContent[]>('/api/search.json', {
default: () => [],
server: false
})
useHead({
meta: [
{ name: 'viewport', content: 'width=device-width, initial-scale=1' }
],
link: [
{ rel: 'icon', href: '/favicon.ico' }
],
htmlAttrs: {
lang: 'en'
}
})
useSeoMeta({
titleTemplate: `%s - ${seo?.siteName}`,
ogSiteName: seo?.siteName,
ogImage: 'https://docs-template.nuxt.dev/social-card.png',
twitterImage: 'https://docs-template.nuxt.dev/social-card.png',
twitterCard: 'summary_large_image'
})
provide('navigation', { navigation, refreshNavigation })
</script>
<template>
<div>
<NuxtLoadingIndicator />
<AppHeader />
<UMain>
<NuxtLayout>
<NuxtPage />
</NuxtLayout>
</UMain>
<AppFooter />
<ClientOnly>
<LazyUContentSearch
:files="files"
:navigation="navigation"
/>
</ClientOnly>
<UNotifications />
</div>
</template>