mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-26 18:00:43 +01:00
docs: pre-render component-meta routes
This commit is contained in:
@@ -10,7 +10,16 @@ export async function fetchComponentMeta (name: string) {
|
|||||||
if (state.value[name]) { return state.value[name] }
|
if (state.value[name]) { return state.value[name] }
|
||||||
|
|
||||||
// Store promise to avoid multiple calls
|
// Store promise to avoid multiple calls
|
||||||
state.value[name] = $fetch(`/api/component-meta/${name}`).then((meta) => {
|
|
||||||
|
// add to nitro prerender
|
||||||
|
if (process.server) {
|
||||||
|
const event = useRequestEvent()
|
||||||
|
event.node.res.setHeader(
|
||||||
|
'x-nitro-prerender',
|
||||||
|
[event.node.res.getHeader('x-nitro-prerender'), `/api/component-meta/${name}.json`].filter(Boolean).join(',')
|
||||||
|
)
|
||||||
|
}
|
||||||
|
state.value[name] = $fetch(`/api/component-meta/${name}.json`).then((meta) => {
|
||||||
state.value[name] = meta
|
state.value[name] = meta
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ export default defineNuxtConfig({
|
|||||||
includeWorkspace: true
|
includeWorkspace: true
|
||||||
},
|
},
|
||||||
routeRules: {
|
routeRules: {
|
||||||
'/': { redirect: '/getting-started' },
|
'/': { redirect: '/getting-started' }
|
||||||
},
|
},
|
||||||
generate: {
|
generate: {
|
||||||
routes: ['/getting-started']
|
routes: ['/getting-started']
|
||||||
|
|||||||
@@ -59,7 +59,7 @@
|
|||||||
"@vueuse/nuxt": "^10.1.2",
|
"@vueuse/nuxt": "^10.1.2",
|
||||||
"eslint": "^8.40.0",
|
"eslint": "^8.40.0",
|
||||||
"nuxt": "^3.4.3",
|
"nuxt": "^3.4.3",
|
||||||
"nuxt-component-meta": "^0.5.1",
|
"nuxt-component-meta": "^0.5.2",
|
||||||
"nuxt-lodash": "^2.4.1",
|
"nuxt-lodash": "^2.4.1",
|
||||||
"standard-version": "^9.5.0",
|
"standard-version": "^9.5.0",
|
||||||
"unbuild": "^1.2.1",
|
"unbuild": "^1.2.1",
|
||||||
|
|||||||
10
yarn.lock
10
yarn.lock
@@ -6800,6 +6800,16 @@ nuxt-component-meta@^0.5.1:
|
|||||||
typescript "^5.0.2"
|
typescript "^5.0.2"
|
||||||
vue-component-meta "^1.2.0"
|
vue-component-meta "^1.2.0"
|
||||||
|
|
||||||
|
nuxt-component-meta@^0.5.2:
|
||||||
|
version "0.5.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/nuxt-component-meta/-/nuxt-component-meta-0.5.2.tgz#11433aea988740619846852ed7e49a7dd703404a"
|
||||||
|
integrity sha512-tjX2JaSRUm9tlxHCZ6cRauJnRm1zPMrPaoHj0dKtwHHXjrcp1+Ou2aL2SjD22mnaZ5ZulcEbyvsqp/oMwVldVQ==
|
||||||
|
dependencies:
|
||||||
|
"@nuxt/kit" "^3.3.1"
|
||||||
|
scule "^1.0.0"
|
||||||
|
typescript "^5.0.2"
|
||||||
|
vue-component-meta "^1.2.0"
|
||||||
|
|
||||||
nuxt-config-schema@^0.4.6:
|
nuxt-config-schema@^0.4.6:
|
||||||
version "0.4.6"
|
version "0.4.6"
|
||||||
resolved "https://registry.yarnpkg.com/nuxt-config-schema/-/nuxt-config-schema-0.4.6.tgz#4ff9b912648ddab8202c232040d5d38d0f14bef3"
|
resolved "https://registry.yarnpkg.com/nuxt-config-schema/-/nuxt-config-schema-0.4.6.tgz#4ff9b912648ddab8202c232040d5d38d0f14bef3"
|
||||||
|
|||||||
Reference in New Issue
Block a user