mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-27 10:20:42 +01:00
docs: improve performances (#570)
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
This commit is contained in:
committed by
Benjamin Canac
parent
1145f88bca
commit
7dff23912d
36
docs/app.vue
36
docs/app.vue
@@ -9,7 +9,6 @@
|
|||||||
<template #left>
|
<template #left>
|
||||||
<UAside :links="anchors">
|
<UAside :links="anchors">
|
||||||
<BranchSelect />
|
<BranchSelect />
|
||||||
|
|
||||||
<UNavigationTree :links="mapContentNavigation(navigation)" />
|
<UNavigationTree :links="mapContentNavigation(navigation)" />
|
||||||
</UAside>
|
</UAside>
|
||||||
</template>
|
</template>
|
||||||
@@ -20,7 +19,7 @@
|
|||||||
</UMain>
|
</UMain>
|
||||||
|
|
||||||
<ClientOnly>
|
<ClientOnly>
|
||||||
<UDocsSearch :files="files" :navigation="navigation" />
|
<LazyUDocsSearch :files="files" :navigation="navigation" />
|
||||||
</ClientOnly>
|
</ClientOnly>
|
||||||
|
|
||||||
<UNotifications>
|
<UNotifications>
|
||||||
@@ -40,24 +39,11 @@ const colorMode = useColorMode()
|
|||||||
const { prefix, removePrefixFromNavigation, removePrefixFromFiles } = useContentSource()
|
const { prefix, removePrefixFromNavigation, removePrefixFromFiles } = useContentSource()
|
||||||
const { mapContentNavigation } = useElementsHelpers()
|
const { mapContentNavigation } = useElementsHelpers()
|
||||||
|
|
||||||
const { data: navigation } = await useLazyAsyncData('navigation', () => fetchContentNavigation(), {
|
const { data: nav } = await useAsyncData('navigation', () => fetchContentNavigation())
|
||||||
|
|
||||||
|
const { data: search } = useLazyFetch('/api/search.json', {
|
||||||
default: () => [],
|
default: () => [],
|
||||||
transform: (navigation) => {
|
server: false
|
||||||
navigation = navigation.find(link => link._path === prefix.value)?.children || []
|
|
||||||
|
|
||||||
return prefix.value === '/main' ? removePrefixFromNavigation(navigation) : navigation
|
|
||||||
},
|
|
||||||
watch: [prefix]
|
|
||||||
})
|
|
||||||
|
|
||||||
const { data: files } = await useLazyAsyncData('files', () => queryContent().where({ _type: 'markdown', navigation: { $ne: false } }).find(), {
|
|
||||||
default: () => [],
|
|
||||||
transform: (files) => {
|
|
||||||
files = files.filter(file => file._path.startsWith(prefix.value))
|
|
||||||
|
|
||||||
return prefix.value === '/main' ? removePrefixFromFiles(files) : files
|
|
||||||
},
|
|
||||||
watch: [prefix]
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const anchors = [{
|
const anchors = [{
|
||||||
@@ -78,6 +64,18 @@ const anchors = [{
|
|||||||
|
|
||||||
// Computed
|
// Computed
|
||||||
|
|
||||||
|
const navigation = computed(() => {
|
||||||
|
const navigation = nav.value.find(link => link._path === prefix.value)?.children || []
|
||||||
|
|
||||||
|
return prefix.value === '/main' ? removePrefixFromNavigation(navigation) : navigation
|
||||||
|
})
|
||||||
|
|
||||||
|
const files = computed(() => {
|
||||||
|
const files = search.value.filter(file => file._path.startsWith(prefix.value))
|
||||||
|
|
||||||
|
return prefix.value === '/main' ? removePrefixFromFiles(files) : files
|
||||||
|
})
|
||||||
|
|
||||||
const color = computed(() => colorMode.value === 'dark' ? '#18181b' : 'white')
|
const color = computed(() => colorMode.value === 'dark' ? '#18181b' : 'white')
|
||||||
|
|
||||||
// Head
|
// Head
|
||||||
|
|||||||
@@ -21,7 +21,6 @@
|
|||||||
|
|
||||||
<template #panel>
|
<template #panel>
|
||||||
<BranchSelect />
|
<BranchSelect />
|
||||||
|
|
||||||
<UNavigationTree :links="mapContentNavigation(navigation)" />
|
<UNavigationTree :links="mapContentNavigation(navigation)" />
|
||||||
</template>
|
</template>
|
||||||
</UHeader>
|
</UHeader>
|
||||||
|
|||||||
@@ -57,12 +57,15 @@ export default defineNuxtConfig({
|
|||||||
},
|
},
|
||||||
nitro: {
|
nitro: {
|
||||||
prerender: {
|
prerender: {
|
||||||
routes: ['/getting-started', '/dev/getting-started']
|
// Waiting for https://github.com/nuxt/nuxt/issues/22763
|
||||||
|
concurrency: 1,
|
||||||
|
routes: [
|
||||||
|
'/getting-started',
|
||||||
|
'/dev/getting-started',
|
||||||
|
'/api/search.json'
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
experimental: {
|
|
||||||
payloadExtraction: false
|
|
||||||
},
|
|
||||||
componentMeta: {
|
componentMeta: {
|
||||||
globalsOnly: true,
|
globalsOnly: true,
|
||||||
exclude: [resolve('./components'), resolve('@nuxthq/elements/components')],
|
exclude: [resolve('./components'), resolve('@nuxthq/elements/components')],
|
||||||
@@ -76,5 +79,16 @@ export default defineNuxtConfig({
|
|||||||
typescript: {
|
typescript: {
|
||||||
strict: false,
|
strict: false,
|
||||||
includeWorkspace: true
|
includeWorkspace: true
|
||||||
|
},
|
||||||
|
hooks: {
|
||||||
|
// TODO: Uncomment after Nuxt v3.7 upgrade
|
||||||
|
// Related to https://github.com/nuxt/nuxt/pull/22558
|
||||||
|
// 'components:extend': (components) => {
|
||||||
|
// components.forEach((component) => {
|
||||||
|
// if (component.global) {
|
||||||
|
// component.global = 'sync'
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
5
docs/server/api/search.json.get.ts
Normal file
5
docs/server/api/search.json.get.ts
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
import { serverQueryContent } from '#content/server'
|
||||||
|
|
||||||
|
export default eventHandler(async (event) => {
|
||||||
|
return serverQueryContent(event).where({ _type: 'markdown', navigation: { $ne: false } }).find()
|
||||||
|
})
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { computed } from 'vue'
|
import { computed } from 'vue'
|
||||||
import { hexToRgb } from '../utils'
|
import { hexToRgb } from '../utils'
|
||||||
import { defineNuxtPlugin, useHead, useAppConfig, useNuxtApp } from '#imports'
|
import { defineNuxtPlugin, useAppConfig } from '#imports'
|
||||||
import colors from '#tailwind-config/theme/colors'
|
import colors from '#tailwind-config/theme/colors'
|
||||||
|
|
||||||
export default defineNuxtPlugin((nuxtApp) => {
|
export default defineNuxtPlugin((nuxtApp) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user