Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions src/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,8 @@
<!-- meta tags -->
<meta name="application-name" content="patrik.mintel.cz" />
<meta name="author" content="Patrik Mintěl" />
<meta
name="keywords"
content="Student,Freelancer,Programátor,Programmer,HTML,CSS,JavaScript,JS,Svelte,SvelteKit,TypeScript,TS,DiscordJS,WebDev,CZ"
/>
<meta name="theme-color" content="#ff7e5b" />
<meta name="color-scheme" content="normal" />
<meta name="robots" content="index, follow" />
</head>

<body data-sveltekit-preload-data="hover" class="bg-background">
Expand Down
37 changes: 35 additions & 2 deletions src/components/Footer.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,36 @@
<footer class="w-full p-2 text-center">
<span class="font-ephesis font-bold">Patrik Mintěl</span> &copy; {new Date().getFullYear()}
<script lang="ts">
import { getState } from '$/lib/state.svelte';

const _state = getState();
const lang = $derived(_state.selectedLang || 'cs');

const footerLinks = $derived([
{ name: _state.lang.navigation.home, href: `/${lang}` },
{ name: _state.lang.navigation.about, href: `/${lang}/about` },
{ name: _state.lang.navigation.projects, href: `/${lang}/projects` },
{ name: _state.lang.navigation.gallery, href: `/${lang}/gallery` },
{ name: _state.lang.gallery.skyMapTitle, href: `/${lang}/gallery/sky-map` },
{ name: _state.lang.navigation.live, href: `/${lang}/live-photo` },
{ name: _state.lang.navigation.movies, href: `/${lang}/movies` },
{ name: _state.lang.navigation.contact, href: `/${lang}/contact` }
]);
</script>

<footer class="border-t border-white/5 px-4 py-6 text-center text-sm text-slate-400">
<nav
aria-label="Footer navigation"
class="mx-auto mb-3 flex max-w-4xl flex-wrap items-center justify-center gap-x-5 gap-y-2"
>
{#each footerLinks as item (item.href)}
<a
href={item.href}
class="text-text-muted hover:text-primary transition-colors duration-200"
>
{item.name}
</a>
{/each}
</nav>
<div>
<span class="font-ephesis text-base font-bold">Patrik Mintěl</span> &copy; {new Date().getFullYear()}
</div>
</footer>
15 changes: 10 additions & 5 deletions src/components/Navigation.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@

let selectedLanguage = $state(_state.selectedLang);
$effect(() => {
let target = `/${selectedLanguage}${_state.path}`;
const cleanPath = _state.path === '/' ? '' : _state.path;
let target = `/${selectedLanguage}${cleanPath}`;
untrack(() => {
if (page.url.pathname !== target) {
const queryParams = page.url.searchParams.toString();
Expand All @@ -120,6 +121,9 @@
});
});

const navHref = (path: string) =>
path === '/' ? `/${selectedLanguage}` : `/${selectedLanguage}${path}`;

let mobileOpened = $state(false);
let dropdownOpen = $state(false);

Expand Down Expand Up @@ -201,7 +205,7 @@
>
<!-- Left: Brand / Title -->
<a
href="/{selectedLanguage}/"
href="/{selectedLanguage}"
class="flex shrink-0 items-center gap-2 align-middle transition-opacity duration-200 hover:opacity-90"
>
<span
Expand All @@ -211,12 +215,12 @@
</a>

<!-- Center: Desktop Navigation -->
<nav class="font-poppins hidden items-center lg:flex">
<nav aria-label="Main navigation" class="font-poppins hidden items-center lg:flex">
<div class="flex flex-nowrap items-center justify-center gap-x-1 xl:gap-x-1.5">
{#each filteredNavigation as item, index (index)}
{@const isActive = _isActive(item)}
<a
href="/{selectedLanguage}{item.path}"
href={navHref(item.path)}
class={[
'flex items-center gap-1.5 rounded-full border px-2.5 py-1.5 text-sm transition-all duration-300 ease-in-out xl:gap-2 xl:px-3.5 xl:py-2 xl:text-base',
isActive
Expand Down Expand Up @@ -336,13 +340,14 @@

<!-- Centered Fullscreen Mobile Menu Items -->
<nav
aria-label="Mobile navigation"
class="font-poppins mx-auto flex w-full max-w-xl flex-1 flex-col items-center justify-center gap-8 pb-16"
>
{#each filteredNavigation as item, index (index)}
{@const isActive = _isActive(item)}
<a
onclick={() => (mobileOpened = false)}
href="/{selectedLanguage}{item.path}"
href={navHref(item.path)}
class={[
'flex w-full max-w-xs items-center justify-center gap-3 rounded-full border px-8 py-3.5 text-center text-xl font-bold transition-all',
isActive
Expand Down
191 changes: 144 additions & 47 deletions src/components/utility/SEO.svelte
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
<script lang="ts">
import { page } from '$app/state';
import {
CANONICAL_ORIGIN,
buildCanonicalUrl,
escapeJsonLd,
toCanonicalAssetUrl,
type PageMeta
} from '$/lib/seo';
import { getState } from '$/lib/state.svelte';

const _state = getState();

const meta = $derived(page.data.meta ?? _state.meta);
const meta = $derived((page.data.meta ?? _state.meta) as PageMeta | undefined);
const selectedLang = $derived(_state.selectedLang || 'cs');
const isCs = $derived(selectedLang === 'cs');

const title = $derived.by(() => {
if (meta?.fullTitle) {
return meta.fullTitle;
}
if (meta?.title) {
return `${meta.title} | Patrik Mintěl`;
}
Expand All @@ -16,58 +28,129 @@
return `${navName} | Patrik Mintěl`;
}
if (!_state.path || _state.path === '' || _state.path === '/') {
return `Patrik Mintěl | Web Developer & Astrophotographer`;
return isCs
? 'Patrik Mintěl | Web Developer & Astrofotograf'
: 'Patrik Mintěl | Web Developer & Astrophotographer';
}
return `Patrik Mintěl`;
return 'Patrik Mintěl';
});

const description = $derived(meta?.description ?? _state.lang?.default_desc ?? '');

const origin = $derived(page.url.origin);
const currentPathWithoutLang = $derived(_state.path || '/');

const canonicalUrl = $derived(
`${origin}/${_state.selectedLang || 'cs'}${currentPathWithoutLang === '/' ? '' : currentPathWithoutLang}`
const robots = $derived(meta?.robots ?? 'index, follow');
const keywords = $derived(
meta?.keywords && meta.keywords.length > 0
? Array.from(new Set(meta.keywords.filter(Boolean))).join(', ')
: ''
);

const csUrl = $derived(
`${origin}/cs${currentPathWithoutLang === '/' ? '' : currentPathWithoutLang}`
);
const currentPathWithoutLang = $derived(_state.path || '/');
const canonicalUrl = $derived(buildCanonicalUrl(selectedLang, currentPathWithoutLang));
const csUrl = $derived(buildCanonicalUrl('cs', currentPathWithoutLang));
const enUrl = $derived(buildCanonicalUrl('en', currentPathWithoutLang));

const enUrl = $derived(
`${origin}/en${currentPathWithoutLang === '/' ? '' : currentPathWithoutLang}`
const imageUrl = $derived(
meta?.image ? toCanonicalAssetUrl(meta.image) : `${CANONICAL_ORIGIN}/images/PFP.jpg`
);

const imageUrl = $derived(meta?.image ?? `${origin}/images/PFP.jpg`);

const imageAlt = $derived(meta?.imageAlt || title);
const pageType = $derived(meta?.type ?? 'website');

const structuredData = $derived(
JSON.stringify({
'@context': 'https://schema.org',
'@graph': [
{
'@type': 'WebSite',
'@id': `${origin}/#website`,
url: origin,
name: 'Patrik Mintěl',
inLanguage: [_state.selectedLang === 'cs' ? 'cs-CZ' : 'en-US']
},
{
'@type': 'Person',
'@id': `${origin}/#person`,
name: 'Patrik Mintěl',
url: origin,
image: `${origin}/images/PFP.jpg`,
jobTitle: 'Software Developer & Astrophotographer',
sameAs: [
'https://github.com/patrick11514',
'https://astrobin.com/users/patrick115'
]
const siteNavItems = $derived([
{
name: _state.lang?.navigation?.gallery || (isCs ? 'Galerie' : 'Gallery'),
url: buildCanonicalUrl(selectedLang, '/gallery')
},
{
name: _state.lang?.navigation?.about || (isCs ? 'O mně' : 'About Me'),
url: buildCanonicalUrl(selectedLang, '/about')
},
{
name: _state.lang?.navigation?.projects || (isCs ? 'Projekty' : 'Projects'),
url: buildCanonicalUrl(selectedLang, '/projects')
},
{
name: _state.lang?.gallery?.skyMapTitle || (isCs ? 'Mapa oblohy' : 'Sky Map'),
url: buildCanonicalUrl(selectedLang, '/gallery/sky-map')
},
{
name: _state.lang?.navigation?.live || (isCs ? 'Astro okénko' : 'Astro Window'),
url: buildCanonicalUrl(selectedLang, '/live-photo')
},
{
name: _state.lang?.navigation?.movies || (isCs ? 'Filmy' : 'Movies'),
url: buildCanonicalUrl(selectedLang, '/movies')
},
{
name: _state.lang?.navigation?.contact || (isCs ? 'Kontakt' : 'Contact'),
url: buildCanonicalUrl(selectedLang, '/contact')
}
]);

const structuredData = $derived.by(() => {
const graph: Record<string, unknown>[] = [
{
'@type': 'WebSite',
'@id': `${CANONICAL_ORIGIN}/#website`,
url: CANONICAL_ORIGIN,
name: 'Patrik Mintěl',
alternateName: ['patrik.mintel.cz', 'patrick115'],
description: _state.lang?.default_desc || '',
inLanguage: ['cs-CZ', 'en-US'],
publisher: {
'@id': `${CANONICAL_ORIGIN}/#person`
}
]
})
);
},
{
'@type': 'Person',
'@id': `${CANONICAL_ORIGIN}/#person`,
name: 'Patrik Mintěl',
alternateName: 'patrick115',
url: CANONICAL_ORIGIN,
image: `${CANONICAL_ORIGIN}/images/PFP.jpg`,
jobTitle: isCs
? 'Vývojář webových aplikací & Astrofotograf'
: 'Software Developer & Astrophotographer',
sameAs: [
'https://github.com/patrick11514',
'https://astrobin.com/users/patrick115'
]
},
{
'@type': 'ItemList',
'@id': `${CANONICAL_ORIGIN}/#navigation`,
name: isCs ? 'Hlavní navigace' : 'Main Navigation',
itemListElement: siteNavItems.map((item, idx) => ({
'@type': 'SiteNavigationElement',
position: idx + 1,
name: item.name,
url: item.url
}))
}
];

if (meta?.breadcrumbs && meta.breadcrumbs.length > 0) {
graph.push({
'@type': 'BreadcrumbList',
'@id': `${canonicalUrl}#breadcrumb`,
itemListElement: meta.breadcrumbs.map((crumb, idx) => ({
'@type': 'ListItem',
position: idx + 1,
name: crumb.name,
item: buildCanonicalUrl(selectedLang, crumb.path)
}))
});
}

if (meta?.structuredData && meta.structuredData.length > 0) {
graph.push(...meta.structuredData);
}

return escapeJsonLd(
JSON.stringify({
'@context': 'https://schema.org',
'@graph': graph
})
);
});

const jsonLdScript = $derived(
`<script type="application/ld+json">${structuredData}</` + `script>`
Expand All @@ -77,6 +160,10 @@
<svelte:head>
<title>{title}</title>
<meta name="description" content={description} />
<meta name="robots" content={robots} />
{#if keywords}
<meta name="keywords" content={keywords} />
{/if}
<link rel="canonical" href={canonicalUrl} />

<!-- Hreflang alternates -->
Expand All @@ -91,17 +178,27 @@
<meta property="og:description" content={description} />
<meta property="og:url" content={canonicalUrl} />
<meta property="og:image" content={imageUrl} />
<meta property="og:locale" content={_state.selectedLang === 'cs' ? 'cs_CZ' : 'en_US'} />
<meta
property="og:locale:alternate"
content={_state.selectedLang === 'cs' ? 'en_US' : 'cs_CZ'}
/>
<meta property="og:image:alt" content={imageAlt} />
<meta property="og:locale" content={isCs ? 'cs_CZ' : 'en_US'} />
<meta property="og:locale:alternate" content={isCs ? 'en_US' : 'cs_CZ'} />
{#if meta?.publishedTime}
<meta property="article:published_time" content={meta.publishedTime} />
{/if}
{#if meta?.modifiedTime}
<meta property="article:modified_time" content={meta.modifiedTime} />
{/if}
{#if meta?.tags && meta.tags.length > 0}
{#each meta.tags as tag (tag)}
<meta property="article:tag" content={tag} />
{/each}
{/if}

<!-- Twitter Cards -->
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content={title} />
<meta name="twitter:description" content={description} />
<meta name="twitter:image" content={imageUrl} />
<meta name="twitter:image:alt" content={imageAlt} />

<!-- Schema.org Structured Data -->
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
Expand Down
14 changes: 14 additions & 0 deletions src/hooks.server.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
import type { Handle } from '@sveltejs/kit';
import { CANONICAL_ORIGIN } from './lib/seo';
import { getClientIp } from './lib/server/network';
import { logVisitor } from './lib/server/visitorLogger';

const LEGACY_HOSTS = new Set(['patrick115.eu', 'www.patrick115.eu']);

export const handle = (async ({ event, resolve }) => {
const host = event.url.hostname.toLowerCase();
if (LEGACY_HOSTS.has(host)) {
const target = `${CANONICAL_ORIGIN}${event.url.pathname}${event.url.search}`;
return new Response(null, {
status: 301,
headers: {
Location: target
}
});
}

const response = await resolve(event, {
transformPageChunk: ({ html }) => html.replace('%lang%', event.params.lang || 'cs')
});
Expand Down
Loading
Loading