Skip to content

Commit 6e61d3d

Browse files
Translate 404 page automatically
1 parent a284ce1 commit 6e61d3d

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

web/astro.config.mjs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ export default defineConfig({
1111
routing: {
1212
prefixDefaultLocale: false,
1313
},
14-
fallback: {
15-
"es": "en",
16-
"fr": "en",
17-
}
1814
},
1915
integrations: [
2016
starlight({

web/src/content.config.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
import { defineCollection } from 'astro:content';
2-
import { docsLoader } from '@astrojs/starlight/loaders';
3-
import { docsSchema } from '@astrojs/starlight/schema';
1+
import { defineCollection, z } from 'astro:content';
2+
import { docsLoader, i18nLoader } from '@astrojs/starlight/loaders';
3+
import { docsSchema, i18nSchema } from '@astrojs/starlight/schema';
44
import { glob } from 'astro/loaders';
55

66
export const collections = {
77
docs: defineCollection({ loader: docsLoader(), schema: docsSchema() }),
8+
i18n: defineCollection({ loader: i18nLoader(), schema: i18nSchema({
9+
extend: z.object({
10+
'custom.label': z.string().optional()
11+
})
12+
}) }),
813
elements: defineCollection({
914
loader: glob({
1015
pattern: "**/*.yaml",

web/src/pages/404.astro

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
---
22
import StarlightPage from '@astrojs/starlight/components/StarlightPage.astro';
33
---
4+
45
<StarlightPage frontmatter={{
56
template: 'splash',
6-
title: 'Page not found (404)',
7+
title: '404',
78
hero: {
8-
title: 'Page not found',
9-
tagline: 'Check the URL or try using the search bar.'
9+
title: '404',
10+
tagline: Astro.locals.t('404.text')
1011
}
1112
}} />

0 commit comments

Comments
 (0)