- Remove duplicate app/projects/ route (was causing 5xx and soft 404) - Fix nginx: redirect www.dk0.dev → dk0.dev (non-www canonical) - Fix not-found.tsx: locale-prefixed links, remove framer-motion dependency - Add fetchPriority='high' and will-change to Hero LCP image - Add preconnect hints for hardcover.app and cms.dk0.dev - Reduce background blur from 100px to 80px (LCP rendering delay) - Remove boneyard-js (~20 KiB), replace with custom Skeleton component - Remove react-icons (~10 KiB), replace with inline SVGs - Conditionally render mobile menu (saves ~20 DOM nodes) - Add /books to sitemap - Optimize image config with explicit deviceSizes/imageSizes
249 lines
11 KiB
TypeScript
249 lines
11 KiB
TypeScript
"use client";
|
|
|
|
import { useState, useEffect, useRef } from "react";
|
|
import Link from "next/link";
|
|
import { usePathname, useSearchParams } from "next/navigation";
|
|
import type { NavTranslations } from "@/types/translations";
|
|
import { ThemeToggle } from "./ThemeToggle";
|
|
|
|
const SiGithubIcon = ({ size = 20 }: { size?: number }) => (
|
|
<svg xmlns="http://www.w3.org/2000/svg" width={size} height={size} viewBox="0 0 24 24" fill="currentColor"><path d="M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"/></svg>
|
|
);
|
|
const SiLinkedinIcon = ({ size = 20 }: { size?: number }) => (
|
|
<svg xmlns="http://www.w3.org/2000/svg" width={size} height={size} viewBox="0 0 24 24" fill="currentColor"><path d="M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433c-1.144 0-2.063-.926-2.063-2.065 0-1.138.92-2.063 2.063-2.063 1.14 0 2.064.925 2.064 2.063 0 1.139-.925 2.065-2.064 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z"/></svg>
|
|
);
|
|
|
|
// Inline SVG icons to avoid loading the full lucide-react chunk (~116KB)
|
|
const MenuIcon = ({ size = 24 }: { size?: number }) => (
|
|
<svg xmlns="http://www.w3.org/2000/svg" width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><line x1="4" x2="20" y1="12" y2="12"/><line x1="4" x2="20" y1="6" y2="6"/><line x1="4" x2="20" y1="18" y2="18"/></svg>
|
|
);
|
|
const XIcon = ({ size = 24 }: { size?: number }) => (
|
|
<svg xmlns="http://www.w3.org/2000/svg" width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>
|
|
);
|
|
const MailIcon = ({ size = 20 }: { size?: number }) => (
|
|
<svg xmlns="http://www.w3.org/2000/svg" width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><rect width="20" height="16" x="2" y="4" rx="2"/><path d="m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"/></svg>
|
|
);
|
|
|
|
interface HeaderClientProps {
|
|
locale: string;
|
|
translations: NavTranslations;
|
|
}
|
|
|
|
export default function HeaderClient({ locale, translations }: HeaderClientProps) {
|
|
const [isOpen, setIsOpen] = useState(false);
|
|
const [scrolled, setScrolled] = useState(false);
|
|
const pathname = usePathname();
|
|
const searchParams = useSearchParams();
|
|
const prevLocale = useRef(locale);
|
|
|
|
useEffect(() => {
|
|
if (prevLocale.current !== locale) {
|
|
window.scrollTo({ top: 0, behavior: "instant" });
|
|
prevLocale.current = locale;
|
|
}
|
|
}, [locale]);
|
|
|
|
const isHome = pathname === `/${locale}` || pathname === `/${locale}/`;
|
|
|
|
useEffect(() => {
|
|
const handleScroll = () => {
|
|
setScrolled(window.scrollY > 50);
|
|
};
|
|
|
|
window.addEventListener("scroll", handleScroll);
|
|
return () => window.removeEventListener("scroll", handleScroll);
|
|
}, []);
|
|
|
|
const navItems = [
|
|
{ name: translations.home, href: `/${locale}` },
|
|
{ name: translations.about, href: isHome ? "#about" : `/${locale}#about` },
|
|
{ name: translations.projects, href: isHome ? "#projects" : `/${locale}/projects` },
|
|
{ name: translations.contact, href: isHome ? "#contact" : `/${locale}#contact` },
|
|
];
|
|
|
|
const socialLinks = [
|
|
{ icon: SiGithubIcon, href: "https://github.com/Denshooter", label: "GitHub" },
|
|
{
|
|
icon: SiLinkedinIcon,
|
|
href: "https://linkedin.com/in/dkonkol",
|
|
label: "LinkedIn",
|
|
},
|
|
{ icon: MailIcon, href: "mailto:contact@dk0.dev", label: "Email" },
|
|
];
|
|
|
|
const pathWithoutLocale = pathname.replace(new RegExp(`^/${locale}`), "") || "";
|
|
const qs = searchParams.toString();
|
|
const query = qs ? `?${qs}` : "";
|
|
const enHref = `/en${pathWithoutLocale}${query}`;
|
|
const deHref = `/de${pathWithoutLocale}${query}`;
|
|
|
|
return (
|
|
<>
|
|
<header className="fixed top-6 left-0 right-0 z-50 flex justify-center px-4 pointer-events-none">
|
|
<div
|
|
className={`pointer-events-auto transition-all duration-500 ease-out ${
|
|
scrolled ? "w-full max-w-5xl" : "w-full max-w-7xl"
|
|
}`}
|
|
>
|
|
<div
|
|
className={`backdrop-blur-xl transition-all duration-500 flex justify-between items-center ${
|
|
scrolled
|
|
? "bg-white/95 border border-stone-200/50 shadow-[0_8px_30px_rgba(0,0,0,0.12)] rounded-full px-6 py-3"
|
|
: "bg-white/85 border border-stone-200/30 shadow-[0_4px_24px_rgba(0,0,0,0.08)] px-4 py-4 rounded-full"
|
|
}`}
|
|
>
|
|
<div className="flex items-center space-x-2 hover:scale-105 transition-transform">
|
|
<Link
|
|
href={`/${locale}`}
|
|
className="text-2xl font-black font-sans text-stone-900 tracking-tighter liquid-hover flex items-center"
|
|
>
|
|
dk<span className="text-red-500">0</span>
|
|
</Link>
|
|
</div>
|
|
|
|
<nav className="hidden md:flex items-center space-x-8">
|
|
{navItems.map((item) => (
|
|
<div key={item.name} className="hover:-translate-y-0.5 active:scale-95 transition-all">
|
|
<Link
|
|
href={item.href}
|
|
className="text-stone-700 hover:text-stone-900 font-medium transition-colors relative liquid-hover"
|
|
>
|
|
{item.name}
|
|
</Link>
|
|
</div>
|
|
))}
|
|
|
|
{/* Language Switcher */}
|
|
<div className="flex items-center space-x-2 ml-4 pl-4 border-l border-stone-300">
|
|
<Link
|
|
href={enHref}
|
|
className={`px-2 py-1 text-sm font-medium rounded transition-all ${
|
|
locale === "en"
|
|
? "bg-stone-900 text-white"
|
|
: "text-stone-600 hover:text-stone-900 hover:bg-stone-100"
|
|
}`}
|
|
>
|
|
EN
|
|
</Link>
|
|
<Link
|
|
href={deHref}
|
|
className={`px-2 py-1 text-sm font-medium rounded transition-all ${
|
|
locale === "de"
|
|
? "bg-stone-900 text-white"
|
|
: "text-stone-600 hover:text-stone-900 hover:bg-stone-100"
|
|
}`}
|
|
>
|
|
DE
|
|
</Link>
|
|
<ThemeToggle />
|
|
</div>
|
|
</nav>
|
|
|
|
<button
|
|
onClick={() => setIsOpen(!isOpen)}
|
|
className="md:hidden p-2 rounded-lg bg-stone-100 hover:bg-stone-200 text-stone-700 transition-all hover:scale-105 active:scale-95"
|
|
aria-label="Toggle menu"
|
|
>
|
|
{isOpen ? <XIcon size={24} /> : <MenuIcon size={24} />}
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</header>
|
|
|
|
{/* Mobile menu overlay */}
|
|
{isOpen && (
|
|
<div
|
|
className="fixed inset-0 bg-stone-900/50 backdrop-blur-sm z-40 md:hidden"
|
|
onClick={() => setIsOpen(false)}
|
|
/>
|
|
)}
|
|
|
|
{/* Mobile menu panel */}
|
|
{isOpen && (
|
|
<div
|
|
className="fixed right-0 top-0 h-full w-80 bg-white shadow-2xl z-50 md:hidden overflow-y-auto"
|
|
>
|
|
<div className="p-6">
|
|
<div className="flex justify-between items-center mb-8">
|
|
<Link
|
|
href={`/${locale}`}
|
|
className="text-2xl font-black text-stone-900"
|
|
onClick={() => setIsOpen(false)}
|
|
>
|
|
dk<span className="text-red-500">0</span>
|
|
</Link>
|
|
<button
|
|
onClick={() => setIsOpen(false)}
|
|
className="p-2 rounded-lg bg-stone-100 hover:bg-stone-200 text-stone-700"
|
|
aria-label="Close menu"
|
|
>
|
|
<XIcon size={24} />
|
|
</button>
|
|
</div>
|
|
|
|
<nav className="space-y-2">
|
|
{navItems.map((item) => (
|
|
<Link
|
|
key={item.name}
|
|
href={item.href}
|
|
onClick={() => setIsOpen(false)}
|
|
className="block px-4 py-3 text-stone-700 hover:bg-stone-50 rounded-lg font-medium transition-colors"
|
|
>
|
|
{item.name}
|
|
</Link>
|
|
))}
|
|
</nav>
|
|
|
|
{/* Language Switcher Mobile */}
|
|
<div className="flex items-center gap-2 mt-6 pt-6 border-t border-stone-200">
|
|
<Link
|
|
href={enHref}
|
|
onClick={() => setIsOpen(false)}
|
|
className={`flex-1 px-4 py-2 text-center font-medium rounded-lg transition-all ${
|
|
locale === "en"
|
|
? "bg-stone-900 text-white"
|
|
: "bg-stone-100 text-stone-600 hover:bg-stone-200"
|
|
}`}
|
|
>
|
|
EN
|
|
</Link>
|
|
<Link
|
|
href={deHref}
|
|
onClick={() => setIsOpen(false)}
|
|
className={`flex-1 px-4 py-2 text-center font-medium rounded-lg transition-all ${
|
|
locale === "de"
|
|
? "bg-stone-900 text-white"
|
|
: "bg-stone-100 text-stone-600 hover:bg-stone-200"
|
|
}`}
|
|
>
|
|
DE
|
|
</Link>
|
|
<ThemeToggle />
|
|
</div>
|
|
|
|
<div className="mt-8 pt-6 border-t border-stone-200">
|
|
<div className="flex justify-center space-x-6">
|
|
{socialLinks.map((link) => {
|
|
const Icon = link.icon;
|
|
return (
|
|
<a
|
|
key={link.label}
|
|
href={link.href}
|
|
target="_blank"
|
|
rel="noopener noreferrer"
|
|
className="p-3 rounded-lg bg-stone-100 hover:bg-stone-900 hover:text-white text-stone-700 transition-all"
|
|
aria-label={link.label}
|
|
>
|
|
<Icon size={20} />
|
|
</a>
|
|
);
|
|
})}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
)}
|
|
</>
|
|
);
|
|
}
|