Skip to content

Commit

Permalink
docs: improve performances (nuxt#570)
Browse files Browse the repository at this point in the history
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
  • Loading branch information
2 people authored and Haythamasalama committed Sep 14, 2023
1 parent 540987a commit 5a8d0d0
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 15 deletions.
47 changes: 42 additions & 5 deletions docs/app.vue
Expand Up @@ -3,11 +3,20 @@
<div>
<Header />

<NuxtLayout>
<NuxtPage />
</NuxtLayout>

<Footer />
<UMain>
<UContainer>
<UPage>
<template #left>
<UAside :links="anchors">
<BranchSelect />
<UNavigationTree :links="mapContentNavigation(navigation)" />
</UAside>
</template>

<NuxtPage />
</UPage>
</UContainer>
</UMain>

<ClientOnly>
<LazyUDocsSearch :files="files" :navigation="navigation" />
Expand Down Expand Up @@ -38,6 +47,22 @@ const { data: search } = useLazyFetch('/api/search.json', {
server: false
})
const anchors = [{
label: 'Documentation',
icon: 'i-heroicons-book-open-solid',
to: '/getting-started'
}, {
label: 'Playground',
icon: 'i-simple-icons-stackblitz',
to: 'https://stackblitz.com/edit/nuxtlabs-ui?file=app.config.ts,app.vue',
target: '_blank'
}, {
label: 'Releases',
icon: 'i-heroicons-rocket-launch-solid',
to: 'https://github.com/nuxtlabs/ui/releases',
target: '_blank'
}]
// Computed
const navigation = computed(() => {
const navigation = nav.value.find(link => link._path === prefix.value)?.children || []
Expand All @@ -51,6 +76,18 @@ const files = computed(() => {
return prefix.value === '/main' ? removePrefixFromFiles(files) : files
})
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')
// Head
Expand Down
1 change: 0 additions & 1 deletion docs/components/Header.vue
Expand Up @@ -28,7 +28,6 @@

<template #panel>
<BranchSelect />

<UNavigationTree :links="mapContentNavigation(navigation)" />
</template>
</UHeader>
Expand Down
18 changes: 10 additions & 8 deletions docs/nuxt.config.ts
Expand Up @@ -60,8 +60,9 @@ export default defineNuxtConfig({
},
nitro: {
prerender: {
// Waiting for https://github.com/nuxt/nuxt/issues/22763
concurrency: 1,
routes: [
'/',
'/getting-started',
'/dev/getting-started',
'/api/search.json'
Expand All @@ -83,13 +84,14 @@ export default defineNuxtConfig({
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'
}
})
}
// 'components:extend': (components) => {
// components.forEach((component) => {
// if (component.global) {
// component.global = 'sync'
// }
// })
// }
}
})
2 changes: 1 addition & 1 deletion src/runtime/plugins/colors.ts
@@ -1,6 +1,6 @@
import { computed } from 'vue'
import { hexToRgb } from '../utils'
import { defineNuxtPlugin, useAppConfig, useNuxtApp, useHead } from '#imports'
import { defineNuxtPlugin, useAppConfig } from '#imports'
import colors from '#tailwind-config/theme/colors'

export default defineNuxtPlugin((nuxtApp) => {
Expand Down

0 comments on commit 5a8d0d0

Please sign in to comment.