docs: add version select (#532)

This commit is contained in:
Benjamin Canac
2023-08-14 22:11:04 +02:00
parent ee663157b7
commit 7e7e9d0f85
25 changed files with 198 additions and 45 deletions

View File

@@ -21,6 +21,8 @@
<script setup lang="ts">
import type { NuxtError } from '#app'
const { prefix, removePrefixFromNavigation, removePrefixFromFiles } = useContentSource()
useSeoMeta({
title: 'Page not found',
description: 'We are sorry but this page could not be found.'
@@ -30,14 +32,26 @@ defineProps<{
error: NuxtError
}>()
const { data: navigation } = await useAsyncData('navigation', () => fetchContentNavigation(), {
default: () => []
const { data: navigation } = await useLazyAsyncData('navigation', () => fetchContentNavigation(), {
default: () => [],
transform: (navigation) => {
navigation = navigation.find(link => link._path === prefix.value)?.children || []
return prefix.value === '/main' ? removePrefixFromNavigation(navigation) : navigation
}
})
const { data: files } = await useLazyAsyncData('files', () => queryContent().where({ _type: 'markdown', navigation: { $ne: false } }).find(), {
default: () => []
default: () => [],
transform: (files) => {
files = files.filter(file => file._path.startsWith(prefix.value))
return prefix.value === '/main' ? removePrefixFromFiles(files) : files
}
})
// Provide
provide('navigation', navigation)
provide('files', files)
</script>