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>
|
||||
<meta name='title' content={title} />
|
||||
<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>
|
||||
@ -1,12 +1,13 @@
|
||||
---
|
||||
import './Header.scss';
|
||||
import { SITE_METADATA } from '@root/config';
|
||||
import ThemeSwitcher from '@components/ThemeSwticher';
|
||||
import { Icon } from 'astro-icon';
|
||||
import NavToggle from './NavToggle';
|
||||
import './Header.scss';
|
||||
import { SITE_METADATA } from '@root/config';
|
||||
import ThemeSwitcher from '@components/ThemeSwticher';
|
||||
import { Icon } from 'astro-icon';
|
||||
import { removeSlashes } from '@utils/string'
|
||||
import NavToggle from './NavToggle';
|
||||
|
||||
const { name, nav, contacts } = SITE_METADATA;
|
||||
const { pathname } = Astro.canonicalURL;
|
||||
const { name, nav, contacts } = SITE_METADATA;
|
||||
const { pathname } = Astro.canonicalURL;
|
||||
---
|
||||
|
||||
<header class='header'>
|
||||
@ -17,11 +18,11 @@ const { pathname } = Astro.canonicalURL;
|
||||
<nav class='header__nav'>
|
||||
<ul class='header__nav-links'>
|
||||
{nav.map((link) => (
|
||||
<li>
|
||||
<a class={pathname.includes(link.url) && 'active'} href={link.url}>
|
||||
{link.name}
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class={removeSlashes(pathname)===removeSlashes(link.url) && 'active' } href={link.url}>
|
||||
{link.name}
|
||||
</a>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<div class='header__nav-contacts'>
|
||||
@ -42,4 +43,4 @@ const { pathname } = Astro.canonicalURL;
|
||||
</nav>
|
||||
<NavToggle client:visible />
|
||||
</div>
|
||||
</header>
|
||||
</header>
|
||||
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