From 587dc0c30cd2b42e384864788205f2c150a17f2b Mon Sep 17 00:00:00 2001 From: Joe Carstairs <65492573+Sycamost@users.noreply.github.com> Date: Sat, 26 Aug 2023 17:07:28 +0100 Subject: Adds 404 page --- src/i18n/translations/pages/404.ts | 21 +++++++++++++++++++++ src/pages/404.astro | 7 +++++++ src/pages/[locale]/not-found.astro | 21 +++++++++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 src/i18n/translations/pages/404.ts create mode 100644 src/pages/404.astro create mode 100644 src/pages/[locale]/not-found.astro (limited to 'src') 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 + hame page? + `, + 'en-GB': () => ` + That page doesn’t exist. Try going to our + home page? + `, + }, +}; + +type Raw = typeof tPage; +export default tPage as TranslationsDictionary; 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); +--- + + 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); +--- + + +
+

{t(tPage, { key: 'title' })}

+

+

+
-- cgit v1.2.3