Fix pre-rendering
Some checks failed
Build and deploy updated apps / Build & deploy (push) Failing after 1m6s

This commit is contained in:
Dominik Milacher 2025-10-14 16:08:03 +02:00
parent dbb9cab101
commit 4a872ad1c6
2 changed files with 16 additions and 0 deletions

View File

@ -0,0 +1,12 @@
<!-- This page just exists to ensure all pages are found during pre-rendered -->
<template>
<NuxtLink :to="buildPrefix(preferredLocale, preferredVariant)"></NuxtLink>
</template>
<script setup lang="ts">
definePageMeta({layout: false}) // crashes otherwise if multiple languages/variants
const {buildPrefix} = useContentPrefix()
const {preferredLocale, preferredVariant} = useContentPreference()
</script>

View File

@ -1,6 +1,10 @@
export default defineNuxtRouteMiddleware((to, from) => { export default defineNuxtRouteMiddleware((to, from) => {
// important: routes do not exist in middleware, never (in)directly use e.g. useRoute // important: routes do not exist in middleware, never (in)directly use e.g. useRoute
if (import.meta.server) {
return // it will interfere with pre-rendering otherwise
}
const {getLocaleVariant, buildPrefix} = useContentPrefix() const {getLocaleVariant, buildPrefix} = useContentPrefix()
const localeVariant = getLocaleVariant(to.path) const localeVariant = getLocaleVariant(to.path)