summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/i18n/translations/pages/404.ts21
-rw-r--r--src/pages/404.astro7
-rw-r--r--src/pages/[locale]/not-found.astro21
3 files changed, 49 insertions, 0 deletions
diff --git a/src/i18n/translations/pages/404.ts b/src/i18n/translations/pages/404.ts
new file mode 100644
index 0000000..d28d297
--- /dev/null
+++ b/src/i18n/translations/pages/404.ts
@@ -0,0 +1,21 @@
+import type { TranslationsDictionary } from '$types/TranslationsDictionary';
+
+const tPage = {
+ title: {
+ sco: () => 'Page no fund',
+ 'en-GB': () => 'Page not found',
+ },
+ message: {
+ sco: () => `
+ Yon page disna exeist. Try gaein til oor
+ <a href="/sco" class="link">hame page</a>?
+ `,
+ 'en-GB': () => `
+ That page doesn’t exist. Try going to our
+ <a href="/en-GB" class="link">home page</a>?
+ `,
+ },
+};
+
+type Raw = typeof tPage;
+export default tPage as TranslationsDictionary<Raw>;
diff --git a/src/pages/404.astro b/src/pages/404.astro
new file mode 100644
index 0000000..447a91e
--- /dev/null
+++ b/src/pages/404.astro
@@ -0,0 +1,7 @@
+---
+import { getLocaleFromPathOrThrow } from '$lib/getLocaleFromPath';
+
+const locale = getLocaleFromPathOrThrow(Astro.url.pathname);
+---
+
+<meta http-equiv="refresh" content={`0;url=/${locale}/not-found`} />
diff --git a/src/pages/[locale]/not-found.astro b/src/pages/[locale]/not-found.astro
new file mode 100644
index 0000000..3b45ba0
--- /dev/null
+++ b/src/pages/[locale]/not-found.astro
@@ -0,0 +1,21 @@
+---
+import translate from '$i18n/translate';
+import tPage from '$i18n/translations/pages/404';
+import Page from '$layouts/Page.astro';
+import { getLocaleFromPathOrThrow } from '$lib/getLocaleFromPath';
+import localeStaticPaths from '$lib/localeStaticPaths';
+
+export async function getStaticPaths() {
+ return localeStaticPaths;
+}
+
+const locale = getLocaleFromPathOrThrow(Astro.url.pathname);
+const t = translate(locale);
+---
+
+<Page title={t(tPage, { key: 'title' })}>
+ <section>
+ <h1>{t(tPage, { key: 'title' })}</h1>
+ <p set:html={t(tPage, { key: 'message' })} />
+ </section>
+</Page>