Rebuild site in Tailwind to match adammaj.com layout with andwati content

- Port adammaj.com layout, sidebar and 3D bookshelf from Chakra to Tailwind v4,
  matched to measured pixel values
- Pages: About, Writing, Reading (bookshelf), Portfolio; content exported to
  markdown with YAML frontmatter, KaTeX math, callouts and YouTube embeds
- Shiki (github-light) code highlighting via rehype-pretty-code
- SEO: per-page metadata and canonicals, JSON-LD, generated OG images,
  sitemap, robots, RSS/JSON feeds, llms.txt
- Umami analytics via PUBLIC_UMAMI_SCRIPT_URL / PUBLIC_UMAMI_WEBSITE_ID
- Prettier + cspell for content, husky/lint-staged pre-commit hook
- Multi-stage Dockerfile (Node 24, pnpm, standalone output) for Dokploy
- Remove unused Chakra, emotion, framer-motion, posthog, next-seo and MDX deps
This commit is contained in:
2026-09-30 12:38:09 +03:00
parent 052f849c5d
commit 63007a1c09
77 changed files with 7923 additions and 112 deletions
+248
View File
@@ -0,0 +1,248 @@
"use client";
import { usePathname, useRouter } from "next/navigation";
import { useEffect, useRef, useState } from "react";
import type { ShelfBook } from "@/lib/books";
const W = 41.5;
const H = 220;
const SPINE = `${W}px`;
const COVER = `${W * 4}px`;
const BOOK = `${W * 5}px`;
const FILTER = "brightness(0.8) contrast(2)";
const PAPER = {
pointerEvents: "none",
opacity: 0.4,
filter: "url(#paper)",
zIndex: 50,
} as const;
export function Bookshelf({ books }: { books: ShelfBook[] }) {
const router = useRouter();
const pathname = usePathname();
const slug = pathname.split("/")[2];
const bookIndex = slug ? books.findIndex((b) => b.slug === slug) : -1;
const viewportRef = useRef<HTMLDivElement>(null);
const timer = useRef<ReturnType<typeof setInterval> | null>(null);
const [scroll, setScroll] = useState(0);
const [inView, setInView] = useState(0);
const [isScrolling, setIsScrolling] = useState(false);
const maxScroll =
(W + 12) * (books.length - inView) + (bookIndex > -1 ? W * 4 : 0) + 5;
const clamp = (x: number) => Math.max(0, Math.min(maxScroll, x));
useEffect(() => {
const el = viewportRef.current;
if (!el) return;
const measure = () => setInView(el.clientWidth / (W + 11));
measure();
const ro = new ResizeObserver(measure);
ro.observe(el);
return () => ro.disconnect();
}, []);
useEffect(() => {
if (bookIndex === -1) setScroll((s) => Math.max(0, s));
else setScroll(Math.max(0, (bookIndex - (inView - 4.5) / 2) * (W + 11)));
}, [bookIndex, inView]);
useEffect(
() => () => {
if (timer.current) clearInterval(timer.current);
},
[],
);
const start = (dir: 1 | -1) => {
if (timer.current) clearInterval(timer.current);
setIsScrolling(true);
timer.current = setInterval(() => setScroll((s) => clamp(s + dir * 3)), 10);
};
const stop = () => {
setIsScrolling(false);
if (timer.current) clearInterval(timer.current);
timer.current = null;
};
const arrow = (dir: 1 | -1) => ({
onMouseEnter: () => start(dir),
onMouseLeave: stop,
onTouchStart: () => start(dir),
onTouchEnd: stop,
});
return (
<>
<svg className="invisible absolute inset-0" aria-hidden="true">
<defs>
<filter id="paper" x="0%" y="0%" width="100%" height="100%">
<feTurbulence
type="fractalNoise"
baseFrequency="0.9"
numOctaves="8"
result="noise"
/>
<feDiffuseLighting
in="noise"
lightingColor="white"
surfaceScale="1"
result="diffLight"
>
<feDistantLight azimuth="45" elevation="35" />
</feDiffuseLighting>
</filter>
</defs>
</svg>
<div className="relative">
<div
className={`absolute -left-7 h-full md:-left-9 ${scroll > 0 ? "block" : "hidden"}`}
>
<div
{...arrow(-1)}
className="flex h-full w-7 items-center justify-center rounded-md max-md:rounded-r-none hover:bg-gray-100"
>
<Chevron dir="left" />
</div>
</div>
<div
ref={viewportRef}
className="flex cursor-grab items-center gap-3 overflow-x-hidden"
>
{books.map((book, i) => {
const open = bookIndex === i;
return (
<button
type="button"
key={book.slug}
onClick={() => router.push(open ? "/reading" : book.href)}
style={{
display: "flex",
alignItems: "center",
justifyContent: "flex-start",
outline: "none",
flexShrink: 0,
transform: `translateX(-${scroll}px)`,
width: open ? BOOK : SPINE,
perspective: "1000px",
transition: isScrolling
? "transform 100ms linear"
: "all 500ms ease",
}}
>
<div
className="flex shrink-0 items-start justify-center"
style={{
width: SPINE,
height: H,
transformOrigin: "right",
backgroundColor: book.spineColor,
color: book.textColor,
transform: `rotateY(${open ? "-60deg" : "0deg"})`,
transition: "all 500ms ease",
filter: FILTER,
transformStyle: "preserve-3d",
}}
>
<span
className="fixed top-0 left-0"
style={{ ...PAPER, height: H, width: SPINE }}
/>
<span
className="mt-3 block select-none overflow-hidden text-ellipsis whitespace-nowrap text-[12px] leading-[1.2] font-bold"
style={{
writingMode: "vertical-rl",
maxHeight: H - 24,
fontFamily: '"DM Sans", sans-serif',
}}
>
{book.title}
</span>
</div>
<div
className="relative shrink-0 overflow-hidden"
style={{
transformOrigin: "left",
transform: `rotateY(${open ? "30deg" : "88.8deg"})`,
transition: "all 500ms ease",
filter: FILTER,
transformStyle: "preserve-3d",
}}
>
<span
className="fixed top-0 right-0"
style={{ ...PAPER, height: H, width: COVER }}
/>
<span
className="absolute top-0 left-0"
style={{
pointerEvents: "none",
zIndex: 50,
height: H,
width: COVER,
background:
"linear-gradient(to right, rgba(255,255,255,0) 2px, rgba(255,255,255,0.5) 3px, rgba(255,255,255,0.25) 4px, rgba(255,255,255,0.25) 6px, transparent 7px, transparent 9px, rgba(255,255,255,0.25) 9px, transparent 12px)",
}}
/>
{book.coverImage ? (
// biome-ignore lint/performance/noImgElement: fixed-size local cover inside a 3D transform
<img
src={book.coverImage}
alt={book.title}
width={W * 4}
height={H}
style={{ width: COVER, height: H }}
/>
) : (
<div
className="flex items-center p-4 text-left text-sm font-bold"
style={{
width: COVER,
height: H,
backgroundColor: book.spineColor,
color: book.textColor,
}}
>
{book.title}
</div>
)}
</div>
</button>
);
})}
</div>
<div
className={`absolute top-0 -right-7 h-full pl-2.5 md:-right-9 ${scroll < maxScroll ? "block" : "hidden"}`}
>
<div
{...arrow(1)}
className="flex h-full w-7 items-center justify-center rounded-md max-md:rounded-l-none hover:bg-gray-100"
>
<Chevron dir="right" />
</div>
</div>
</div>
</>
);
}
function Chevron({ dir }: { dir: "left" | "right" }) {
return (
<svg
viewBox="0 0 24 24"
className="size-3"
fill="none"
stroke="currentColor"
strokeWidth="3"
strokeLinecap="round"
strokeLinejoin="round"
aria-hidden="true"
>
<path d={dir === "left" ? "M15 4l-8 8 8 8" : "M9 4l8 8-8 8"} />
</svg>
);
}
+29
View File
@@ -0,0 +1,29 @@
/** Renders a JSON-LD block. `<` is escaped so content can't close the script tag. */
export function JsonLd({
data,
}: {
data: Record<string, unknown> | Record<string, unknown>[];
}) {
return (
<script
type="application/ld+json"
// biome-ignore lint/security/noDangerouslySetInnerHtml: JSON-LD must be inlined; `<` is escaped
dangerouslySetInnerHTML={{
__html: JSON.stringify(data).replace(/</g, "\\u003c"),
}}
/>
);
}
export function breadcrumbs(items: { name: string; url: string }[]) {
return {
"@context": "https://schema.org",
"@type": "BreadcrumbList",
itemListElement: items.map((item, i) => ({
"@type": "ListItem",
position: i + 1,
name: item.name,
item: item.url,
})),
};
}
+15
View File
@@ -0,0 +1,15 @@
import { MobileNav } from "@/components/MobileNav";
import { Sidebar } from "@/components/Sidebar";
// Mirrors adammaj.com: a 596px wrapper (Chakra container) centred on the page, with a
// second, equally wide container inside it whose 16px padding offsets the text column.
export function Layout({ children }: { children: React.ReactNode }) {
return (
<div className="relative mx-auto mt-16 w-full max-w-[596.161px] px-4 pb-8 md:pb-40">
<div className="fixed inset-x-0 top-0 z-100 hidden h-16 bg-white lg:block" />
<MobileNav />
<Sidebar />
<main className="relative px-4 md:w-[596.161px]">{children}</main>
</div>
);
}
+33
View File
@@ -0,0 +1,33 @@
import { MDXRemote } from "next-mdx-remote/rsc";
import rehypeKatex from "rehype-katex";
import rehypePrettyCode from "rehype-pretty-code";
import rehypeRaw from "rehype-raw";
import remarkGfm from "remark-gfm";
import remarkMath from "remark-math";
/** Renders exported markdown: GFM, raw HTML (callouts, embeds), and KaTeX math. */
export function Mdx({ source }: { source: string }) {
return (
<MDXRemote
source={source}
options={{
mdxOptions: {
format: "md",
remarkPlugins: [remarkGfm, remarkMath],
rehypePlugins: [
rehypeRaw,
rehypeKatex,
[
rehypePrettyCode,
{
theme: "github-light",
keepBackground: false,
defaultLanguage: "txt",
},
],
],
},
}}
/>
);
}
+85
View File
@@ -0,0 +1,85 @@
"use client";
import { usePathname } from "next/navigation";
import { useEffect, useRef, useState } from "react";
import { NavLink } from "@/components/NavLink";
import { site } from "@/lib/site";
export function MobileNav() {
const [open, setOpen] = useState(false);
const ref = useRef<HTMLDivElement>(null);
const pathname = usePathname();
// biome-ignore lint/correctness/useExhaustiveDependencies: close the menu when the route changes
useEffect(() => setOpen(false), [pathname]);
useEffect(() => {
if (!open) return;
const close = (e: MouseEvent) => {
if (!ref.current?.contains(e.target as Node)) setOpen(false);
};
document.addEventListener("mousedown", close);
return () => document.removeEventListener("mousedown", close);
}, [open]);
return (
<header className="fixed inset-x-0 top-0 z-50 h-12 border-b border-gray-200 bg-white lg:hidden">
<div className="mx-auto flex h-full max-w-5xl items-center justify-between px-8">
<div className="flex gap-8">
{site.nav.slice(0, 3).map((item) => (
<NavLink key={item.href} href={item.href}>
{item.name}
</NavLink>
))}
</div>
<div ref={ref} className="relative">
<button
type="button"
aria-label="Menu"
aria-expanded={open}
onClick={() => setOpen(!open)}
className="flex h-8 w-8 items-center justify-center rounded-md border border-gray-200 hover:bg-gray-100"
>
<svg
viewBox="0 0 24 24"
className="size-4"
fill="none"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
aria-hidden="true"
>
<path d="M3 12h18M3 6h18M3 18h18" />
</svg>
</button>
{open && (
<div className="absolute right-0 top-10 flex w-44 flex-col gap-4 rounded-md border border-gray-200 bg-white py-4 shadow-lg">
<div className="flex flex-col gap-3 px-4">
<h2 className="text-xs font-bold">NAVIGATION</h2>
{site.nav.map((item) => (
<NavLink key={item.href} href={item.href}>
{item.name}
</NavLink>
))}
</div>
<div className="flex flex-col gap-3 px-4">
<h2 className="text-xs font-bold">FIND ME ON</h2>
{site.social.map((item) => (
<a
key={item.href}
href={item.href}
target="_blank"
rel="noopener noreferrer"
className="text-gray-500 hover:text-black"
>
{item.name}
</a>
))}
</div>
</div>
)}
</div>
</div>
</header>
);
}
+25
View File
@@ -0,0 +1,25 @@
"use client";
import Link from "next/link";
import { usePathname } from "next/navigation";
export function NavLink({
href,
className = "",
children,
}: {
href: string;
className?: string;
children: React.ReactNode;
}) {
const pathname = usePathname();
const active = href === "/" ? pathname === "/" : pathname.startsWith(href);
return (
<Link
href={href}
className={`${active ? "text-black" : "text-[#718096]"} hover:text-black ${className}`}
>
{children}
</Link>
);
}
+35
View File
@@ -0,0 +1,35 @@
import { NavLink } from "@/components/NavLink";
import { site } from "@/lib/site";
const link = "mt-2 block w-fit text-[18px] leading-[27px]";
export function Sidebar() {
return (
<aside className="absolute right-full mr-40 hidden lg:flex">
<div className="fixed flex flex-col items-start whitespace-nowrap">
<nav>
<p className="text-[13.3333px] leading-5 font-bold">NAVIGATION</p>
{site.nav.map((item) => (
<NavLink key={item.href} href={item.href} className={link}>
{item.name}
</NavLink>
))}
</nav>
<div className="mt-10">
<p className="text-[13.3333px] leading-5 font-bold">FIND ME ON</p>
{site.social.map((item) => (
<a
key={item.href}
href={item.href}
target="_blank"
rel="noopener noreferrer"
className={`${link} text-gray-500 hover:text-black`}
>
{item.name}
</a>
))}
</div>
</div>
</aside>
);
}