chore: add 404 page
This commit is contained in:
24
src/pages/404.astro
Normal file
24
src/pages/404.astro
Normal file
@@ -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
|
||||
}
|
||||
---
|
||||
|
||||
<Layout title={siteTitle} description={siteDescription}>
|
||||
<div class="min-h-screen grid content-center justify-items-center">
|
||||
<div>404</div>
|
||||
<div>Страница не найдена</div>
|
||||
<a href="/" class="text-blue-600 hover:text-blue-700">На главную</a>
|
||||
</div>
|
||||
</Layout>
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user