redirect to english if page is missing

This commit is contained in:
Ulf Gebhardt 2026-03-04 14:35:11 +01:00
parent ad433e9888
commit a4356ada40
Signed by: ulfgebhardt
GPG Key ID: DA6B843E748679C9

View File

@ -250,6 +250,26 @@ export default hopeTheme({
'/fr/': ['fr-FR', 'fr'],
},
localeFallback: false,
// Redirect to English for pages missing in other locales
config: (app) => {
const fallback = '/en/'
const locales = ['/de/', '/es/', '/fr/']
const pagePaths = new Set(app.pages.map((p) => p.path))
const enPages = app.pages.filter((p) => p.path.startsWith(fallback)).map((p) => p.path)
const redirects = {}
for (const locale of locales) {
for (const enPath of enPages) {
const localePath = enPath.replace(fallback, locale)
if (!pagePaths.has(localePath)) {
redirects[localePath] = enPath
}
}
}
return redirects
},
},
slimsearch: {
indexContent: true,