mirror of
https://github.com/sergeyyarkov/yarkov.tech.git
synced 2026-10-11 18:39:14 +03:00
feat: added 404 page
This commit is contained in:
parent
51d628d810
commit
d0882b41ea
1
public/assets/js/detect-theme.min.js
vendored
Normal file
1
public/assets/js/detect-theme.min.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
window.theme=(()=>{const e=localStorage.getItem("theme");if(e&&("dark"===e||"light"===e))return e;const t=window.matchMedia("(prefers-color-scheme: dark)").matches;return t?"dark":"light"})(),document.documentElement.setAttribute("data-theme",window.theme),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",({matches:e})=>{window.theme=e?"dark":"light",localStorage.setItem("theme",window.theme),document.documentElement.setAttribute("data-theme",window.theme)});
|
||||||
@ -21,5 +21,5 @@
|
|||||||
</title>
|
</title>
|
||||||
<meta name='title' content={title} />
|
<meta name='title' content={title} />
|
||||||
<meta name='description' content={description || SITE_METADATA.description} />
|
<meta name='description' content={description || SITE_METADATA.description} />
|
||||||
<script is:inline src='assets/js/detect-theme.js' />
|
<script is:inline src='assets/js/detect-theme.min.js' />
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
@ -3,6 +3,7 @@ import './Header.scss';
|
|||||||
import { SITE_METADATA } from '@root/config';
|
import { SITE_METADATA } from '@root/config';
|
||||||
import ThemeSwitcher from '@components/ThemeSwticher';
|
import ThemeSwitcher from '@components/ThemeSwticher';
|
||||||
import { Icon } from 'astro-icon';
|
import { Icon } from 'astro-icon';
|
||||||
|
import { removeSlashes } from '@utils/string'
|
||||||
import NavToggle from './NavToggle';
|
import NavToggle from './NavToggle';
|
||||||
|
|
||||||
const { name, nav, contacts } = SITE_METADATA;
|
const { name, nav, contacts } = SITE_METADATA;
|
||||||
@ -18,7 +19,7 @@ const { pathname } = Astro.canonicalURL;
|
|||||||
<ul class='header__nav-links'>
|
<ul class='header__nav-links'>
|
||||||
{nav.map((link) => (
|
{nav.map((link) => (
|
||||||
<li>
|
<li>
|
||||||
<a class={pathname.includes(link.url) && 'active'} href={link.url}>
|
<a class={removeSlashes(pathname)===removeSlashes(link.url) && 'active' } href={link.url}>
|
||||||
{link.name}
|
{link.name}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
10
src/pages/404.astro
Normal file
10
src/pages/404.astro
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
import PageLayout from '@layouts/default.astro'
|
||||||
|
---
|
||||||
|
|
||||||
|
<PageLayout title="404" showPageHeading={false}>
|
||||||
|
<div class="container">
|
||||||
|
<h1 style="font-size:var(--font-size-5xl);">404</h1>
|
||||||
|
<p>Страницу которую вы пытаетесь найти не существует.</p>
|
||||||
|
</div>
|
||||||
|
</PageLayout>
|
||||||
3
src/utils/string.ts
Normal file
3
src/utils/string.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export function removeSlashes(string: string): string {
|
||||||
|
return string.replaceAll('/', '');
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user