From df4a48f124f4af0ef1a04080874f9cf072fe7de6 Mon Sep 17 00:00:00 2001 From: Zotov Ivan Yuryevich Date: Wed, 17 Jun 2026 22:53:04 +0300 Subject: [PATCH] chore: add 404 page --- src/pages/404.astro | 24 ++++++++++++++++++++++++ src/pages/[slug].astro | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 src/pages/404.astro diff --git a/src/pages/404.astro b/src/pages/404.astro new file mode 100644 index 0000000..a27d1d2 --- /dev/null +++ b/src/pages/404.astro @@ -0,0 +1,24 @@ +--- +import Layout from '../layouts/Layout.astro' +import '../styles/globals.css' +import { siteConfigQuery } from '../graphql-documents/site-config.gql.generated' + +let siteTitle = '' +let siteDescription = '' + +try { + const siteResult = await siteConfigQuery.execute() + siteTitle = siteResult.data?.siteConfig?.title ?? '' + siteDescription = siteResult.data?.siteConfig?.description ?? '' +} catch { + // CMS may be unavailable on error pages +} +--- + + +
+
404
+
Страница не найдена
+ На главную +
+
diff --git a/src/pages/[slug].astro b/src/pages/[slug].astro index e3e7c36..e861c15 100644 --- a/src/pages/[slug].astro +++ b/src/pages/[slug].astro @@ -54,7 +54,7 @@ if (categoryResult.errors?.length) { const category = categoryResult.data?.categories?.find(c => c != null) if (!category) { - throw new Error(`Category not found for slug: ${slug}`) + return new Response(null, { status: 404, statusText: 'Not Found' }) } const title = category.title ?? undefined