mirror of
https://github.com/andwati/andwati-nextgen.git
synced 2026-11-19 18:48:46 +00:00
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:
Binary file not shown.
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 15 KiB |
@@ -0,0 +1,29 @@
|
||||
import { getFeedItems } from "@/lib/feed";
|
||||
import { abs, site } from "@/lib/site";
|
||||
|
||||
export const dynamic = "force-static";
|
||||
|
||||
export async function GET() {
|
||||
const items = await getFeedItems();
|
||||
const feed = {
|
||||
version: "https://jsonfeed.org/version/1.1",
|
||||
title: site.name,
|
||||
home_page_url: site.baseUrl,
|
||||
feed_url: abs("/feed.json"),
|
||||
description: site.description,
|
||||
language: "en",
|
||||
authors: [{ name: site.name, url: site.baseUrl }],
|
||||
items: items.map((i) => ({
|
||||
id: i.url,
|
||||
url: i.url,
|
||||
title: i.title,
|
||||
summary: i.description,
|
||||
content_html: i.html,
|
||||
date_published: i.date.toISOString(),
|
||||
tags: i.tags,
|
||||
})),
|
||||
};
|
||||
return new Response(JSON.stringify(feed), {
|
||||
headers: { "Content-Type": "application/feed+json; charset=utf-8" },
|
||||
});
|
||||
}
|
||||
+103
-18
@@ -1,26 +1,111 @@
|
||||
@import "tailwindcss";
|
||||
@plugin "@tailwindcss/typography";
|
||||
|
||||
:root {
|
||||
--background: #ffffff;
|
||||
--foreground: #171717;
|
||||
}
|
||||
@theme {
|
||||
--breakpoint-sm: 30rem;
|
||||
--breakpoint-lg: 62rem;
|
||||
|
||||
@theme inline {
|
||||
--color-background: var(--background);
|
||||
--color-foreground: var(--foreground);
|
||||
--font-sans: var(--font-geist-sans);
|
||||
--font-mono: var(--font-geist-mono);
|
||||
}
|
||||
--font-sans: var(--font-lora), ui-serif, Georgia, serif;
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
:root {
|
||||
--background: #0a0a0a;
|
||||
--foreground: #ededed;
|
||||
}
|
||||
--color-gray-100: #edf2f7;
|
||||
--color-gray-200: #e2e8f0;
|
||||
--color-gray-400: #a0aec0;
|
||||
--color-gray-500: #718096;
|
||||
--color-gray-600: #4a5568;
|
||||
--color-gray-800: #1a202c;
|
||||
--color-blue-500: #3182ce;
|
||||
--color-blue-600: #2b6cb0;
|
||||
}
|
||||
|
||||
body {
|
||||
background: var(--background);
|
||||
color: var(--foreground);
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
background: #fff;
|
||||
color: var(--color-gray-800);
|
||||
font-family: var(--font-sans);
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
/* Prose overrides mirroring adammaj.com's chakra-ui-prose config */
|
||||
hr {
|
||||
width: 100%;
|
||||
height: 0;
|
||||
border: 0;
|
||||
border-bottom: 1px solid var(--color-gray-200);
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
.prose {
|
||||
line-height: 1.5;
|
||||
--tw-prose-body: var(--color-gray-800);
|
||||
--tw-prose-headings: var(--color-gray-800);
|
||||
--tw-prose-links: var(--color-blue-500);
|
||||
max-width: none;
|
||||
}
|
||||
.prose :where(h1, h2, h3, h4):not(:where(.not-prose *)) {
|
||||
margin-top: 1rem;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
.prose :where(p):not(:where(.not-prose *)) {
|
||||
margin-top: 0.75rem;
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
.prose :where(a):not(:where(.not-prose *)) {
|
||||
color: var(--color-blue-500);
|
||||
font-weight: inherit;
|
||||
text-decoration: underline;
|
||||
}
|
||||
.prose :where(pre):not(:where(.not-prose *)) {
|
||||
background: #f6f8fa;
|
||||
color: var(--color-gray-800);
|
||||
border: 1px solid #e1e4e8;
|
||||
}
|
||||
.prose :where(code):not(:where(pre *)):not(:where(.not-prose *))::before,
|
||||
.prose :where(code):not(:where(pre *)):not(:where(.not-prose *))::after {
|
||||
content: none;
|
||||
}
|
||||
|
||||
.callout {
|
||||
margin: 1rem 0;
|
||||
padding: 0.25rem 1rem;
|
||||
border-left: 4px solid var(--color-blue-500);
|
||||
border-radius: 0 0.375rem 0.375rem 0;
|
||||
background: rgb(49 130 206 / 0.05);
|
||||
}
|
||||
.callout-tip {
|
||||
border-color: #10b981;
|
||||
background: rgb(16 185 129 / 0.05);
|
||||
}
|
||||
.callout-warning {
|
||||
border-color: #f59e0b;
|
||||
background: rgb(245 158 11 / 0.05);
|
||||
}
|
||||
.callout-danger {
|
||||
border-color: #ef4444;
|
||||
background: rgb(239 68 68 / 0.05);
|
||||
}
|
||||
|
||||
.youtube {
|
||||
position: relative;
|
||||
margin: 1rem 0;
|
||||
aspect-ratio: 16 / 9;
|
||||
overflow: hidden;
|
||||
border-radius: 0.375rem;
|
||||
}
|
||||
.youtube iframe {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
/* Shiki (rehype-pretty-code): theme colours are inline; keep block chrome from .prose pre */
|
||||
pre[data-language] {
|
||||
overflow-x: auto;
|
||||
padding: 1rem;
|
||||
border-radius: 0.375rem;
|
||||
font-size: 0.875rem;
|
||||
line-height: 1.6;
|
||||
}
|
||||
pre[data-language] code {
|
||||
background: none;
|
||||
padding: 0;
|
||||
font-size: inherit;
|
||||
}
|
||||
|
||||
+76
-15
@@ -1,29 +1,90 @@
|
||||
import type { Metadata } from "next";
|
||||
import { Geist, Geist_Mono } from "next/font/google";
|
||||
import type { Metadata, Viewport } from "next";
|
||||
import { Lora } from "next/font/google";
|
||||
import Script from "next/script";
|
||||
import { JsonLd } from "@/components/JsonLd";
|
||||
import { Layout } from "@/components/Layout";
|
||||
import { site } from "@/lib/site";
|
||||
import "./globals.css";
|
||||
import "katex/dist/katex.min.css";
|
||||
|
||||
const geistSans = Geist({
|
||||
variable: "--font-geist-sans",
|
||||
const lora = Lora({
|
||||
variable: "--font-lora",
|
||||
subsets: ["latin"],
|
||||
display: "swap",
|
||||
});
|
||||
|
||||
const geistMono = Geist_Mono({
|
||||
variable: "--font-geist-mono",
|
||||
subsets: ["latin"],
|
||||
});
|
||||
export const viewport: Viewport = { themeColor: "#ffffff" };
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Create Next App",
|
||||
description: "Generated by create next app",
|
||||
metadataBase: new URL(site.baseUrl),
|
||||
title: { default: site.title, template: `%s | ${site.name}` },
|
||||
description: site.description,
|
||||
keywords: site.keywords,
|
||||
authors: [{ name: site.name, url: site.baseUrl }],
|
||||
creator: site.name,
|
||||
publisher: site.name,
|
||||
openGraph: {
|
||||
siteName: site.name,
|
||||
type: "website",
|
||||
locale: site.locale,
|
||||
url: "/",
|
||||
title: site.title,
|
||||
description: site.description,
|
||||
},
|
||||
twitter: {
|
||||
card: "summary_large_image",
|
||||
site: site.twitter,
|
||||
creator: site.twitter,
|
||||
},
|
||||
robots: {
|
||||
index: true,
|
||||
follow: true,
|
||||
googleBot: {
|
||||
index: true,
|
||||
follow: true,
|
||||
"max-image-preview": "large",
|
||||
"max-snippet": -1,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const websiteLd = {
|
||||
"@context": "https://schema.org",
|
||||
"@type": "WebSite",
|
||||
name: site.name,
|
||||
alternateName: site.tagline,
|
||||
url: site.baseUrl,
|
||||
inLanguage: "en",
|
||||
author: { "@type": "Person", name: site.name },
|
||||
};
|
||||
|
||||
const umamiScript = process.env.PUBLIC_UMAMI_SCRIPT_URL;
|
||||
const umamiId = process.env.PUBLIC_UMAMI_WEBSITE_ID;
|
||||
|
||||
export default function RootLayout({ children }: LayoutProps<"/">) {
|
||||
return (
|
||||
<html
|
||||
lang="en"
|
||||
className={`${geistSans.variable} ${geistMono.variable} h-full antialiased`}
|
||||
>
|
||||
<body className="min-h-full flex flex-col">{children}</body>
|
||||
<html lang="en" className={lora.variable}>
|
||||
<head>
|
||||
<link
|
||||
rel="alternate"
|
||||
type="application/rss+xml"
|
||||
title={`${site.name} RSS`}
|
||||
href="/rss.xml"
|
||||
/>
|
||||
<link
|
||||
rel="alternate"
|
||||
type="application/feed+json"
|
||||
title={`${site.name} JSON Feed`}
|
||||
href="/feed.json"
|
||||
/>
|
||||
</head>
|
||||
<body>
|
||||
<JsonLd data={websiteLd} />
|
||||
<Layout>{children}</Layout>
|
||||
{umamiScript && umamiId && (
|
||||
<Script defer src={umamiScript} data-website-id={umamiId} />
|
||||
)}
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
import { getBooks, getWritings } from "@/lib/content";
|
||||
import { abs, site } from "@/lib/site";
|
||||
|
||||
export const dynamic = "force-static";
|
||||
|
||||
export function GET() {
|
||||
const body = `# ${site.name}
|
||||
|
||||
> ${site.description}
|
||||
|
||||
${site.name} (also known as ${site.alias}) is a software engineer and the captain of the binarysith CTF team. This site collects his original essays, CTF writeups, reading list and projects.
|
||||
|
||||
## Writing
|
||||
|
||||
${getWritings()
|
||||
.map(
|
||||
(p) =>
|
||||
`- [${p.data.title}](${abs(`/writing/${p.slug}`)})${p.data.description ? `: ${p.data.description}` : ""}`,
|
||||
)
|
||||
.join("\n")}
|
||||
|
||||
## Reading
|
||||
|
||||
${getBooks()
|
||||
.map((b) => `- [${b.data.title}](${abs(`/reading/${b.slug}`)})`)
|
||||
.join("\n")}
|
||||
|
||||
## Other
|
||||
|
||||
- [About](${abs("/")})
|
||||
- [Portfolio](${abs("/portfolio")})
|
||||
- [RSS](${abs("/rss.xml")})
|
||||
- [Sitemap](${abs("/sitemap.xml")})
|
||||
`;
|
||||
return new Response(body, {
|
||||
headers: { "Content-Type": "text/plain; charset=utf-8" },
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
export default function NotFound() {
|
||||
redirect("/");
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import { ogContentType, ogImage, ogSize } from "@/lib/og";
|
||||
import { site } from "@/lib/site";
|
||||
|
||||
export const alt = site.title;
|
||||
export const size = ogSize;
|
||||
export const contentType = ogContentType;
|
||||
|
||||
export default function Image() {
|
||||
return ogImage(site.name, "Software engineer · CTF player");
|
||||
}
|
||||
+38
-63
@@ -1,69 +1,44 @@
|
||||
import Image from "next/image";
|
||||
import type { Metadata } from "next";
|
||||
import { JsonLd } from "@/components/JsonLd";
|
||||
import { Mdx } from "@/components/Mdx";
|
||||
import { getAbout } from "@/lib/content";
|
||||
import { site } from "@/lib/site";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
alternates: { canonical: "/" },
|
||||
};
|
||||
|
||||
const personLd = {
|
||||
"@context": "https://schema.org",
|
||||
"@type": "Person",
|
||||
name: site.name,
|
||||
alternateName: site.alias,
|
||||
url: site.baseUrl,
|
||||
jobTitle: "Software Engineer",
|
||||
description: site.description,
|
||||
sameAs: site.sameAs,
|
||||
knowsAbout: [
|
||||
"Cyber security",
|
||||
"Capture the flag",
|
||||
"Binary exploitation",
|
||||
"Reverse engineering",
|
||||
"Low-level programming",
|
||||
"Distributed systems",
|
||||
"Compiler design",
|
||||
"Database internals",
|
||||
],
|
||||
memberOf: {
|
||||
"@type": "Organization",
|
||||
name: "binarysith",
|
||||
url: "https://ctftime.org/team/379200",
|
||||
},
|
||||
};
|
||||
|
||||
export default function Home() {
|
||||
return (
|
||||
<div className="flex flex-col flex-1 items-center justify-center bg-zinc-50 font-sans dark:bg-black">
|
||||
<main className="flex flex-1 w-full max-w-3xl flex-col items-center justify-between py-32 px-16 bg-white dark:bg-black sm:items-start">
|
||||
<Image
|
||||
className="dark:invert h-5 w-[100px]"
|
||||
src="/next.svg"
|
||||
alt="Next.js logo"
|
||||
width={100}
|
||||
height={20}
|
||||
priority
|
||||
/>
|
||||
<div className="flex flex-col items-center gap-6 text-center sm:items-start sm:text-left">
|
||||
<h1 className="max-w-xs text-3xl font-semibold leading-10 tracking-tight text-black dark:text-zinc-50">
|
||||
To get started, edit the{" "}
|
||||
<code className="rounded bg-black/[.06] px-1.5 py-0.5 font-mono text-[0.9em] dark:bg-white/[.08]">
|
||||
page.tsx
|
||||
</code>{" "}
|
||||
file.
|
||||
</h1>
|
||||
<p className="max-w-md text-lg leading-8 text-zinc-600 dark:text-zinc-400">
|
||||
Looking for a starting point or more instructions? Head over to{" "}
|
||||
<a
|
||||
href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
|
||||
className="font-medium text-zinc-950 dark:text-zinc-50"
|
||||
>
|
||||
Templates
|
||||
</a>{" "}
|
||||
or the{" "}
|
||||
<a
|
||||
href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
|
||||
className="font-medium text-zinc-950 dark:text-zinc-50"
|
||||
>
|
||||
Learning
|
||||
</a>{" "}
|
||||
center.
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex flex-col gap-4 text-base font-medium sm:flex-row">
|
||||
<a
|
||||
className="flex h-12 w-full items-center justify-center gap-2 rounded-full bg-foreground px-5 text-background transition-colors hover:bg-[#383838] dark:hover:bg-[#ccc] md:w-[158px]"
|
||||
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<Image
|
||||
className="dark:invert h-[14px] w-4"
|
||||
src="/vercel.svg"
|
||||
alt="Vercel logomark"
|
||||
width={16}
|
||||
height={14}
|
||||
/>
|
||||
Deploy Now
|
||||
</a>
|
||||
<a
|
||||
className="flex h-12 w-full items-center justify-center rounded-full border border-solid border-black/[.08] px-5 transition-colors hover:border-transparent hover:bg-black/[.04] dark:border-white/[.145] dark:hover:bg-[#1a1a1a] md:w-[158px]"
|
||||
href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
Documentation
|
||||
</a>
|
||||
</div>
|
||||
</main>
|
||||
<div className="prose">
|
||||
<JsonLd data={personLd} />
|
||||
<Mdx source={getAbout()} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
import type { Metadata } from "next";
|
||||
import { Mdx } from "@/components/Mdx";
|
||||
import { getPortfolio } from "@/lib/content";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Portfolio",
|
||||
description: "Projects and infrastructure-level software by Ian Andwati.",
|
||||
alternates: { canonical: "/portfolio" },
|
||||
};
|
||||
|
||||
export default function PortfolioPage() {
|
||||
const items = getPortfolio();
|
||||
return (
|
||||
<div className="flex flex-col gap-4">
|
||||
<h1 className="sr-only">Portfolio</h1>
|
||||
<hr />
|
||||
{items.map((item) => (
|
||||
<div key={item.slug} className="flex flex-col gap-4">
|
||||
<div className="flex flex-col gap-1">
|
||||
<h2 className="font-bold">{item.data.title}</h2>
|
||||
<p className="pb-4 text-sm text-gray-600">
|
||||
{item.data.description}
|
||||
</p>
|
||||
<div className="prose text-sm text-gray-600">
|
||||
<Mdx source={item.content} />
|
||||
</div>
|
||||
<div className="flex gap-6 pt-2">
|
||||
{item.data.links?.map((l) => (
|
||||
<a
|
||||
key={l.url}
|
||||
href={l.url}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="text-sm text-blue-600 hover:underline"
|
||||
>
|
||||
{l.label}
|
||||
</a>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<hr />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import { getBooks } from "@/lib/content";
|
||||
import { ogContentType, ogImage, ogSize } from "@/lib/og";
|
||||
|
||||
export const size = ogSize;
|
||||
export const contentType = ogContentType;
|
||||
|
||||
export function generateStaticParams() {
|
||||
return getBooks().map((b) => ({ slug: b.slug }));
|
||||
}
|
||||
|
||||
export default async function Image({
|
||||
params,
|
||||
}: {
|
||||
params: Promise<{ slug: string }>;
|
||||
}) {
|
||||
const { slug } = await params;
|
||||
const book = getBooks().find((b) => b.slug === slug);
|
||||
return ogImage(book?.data.title ?? "Reading", "Reading");
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
import type { Metadata } from "next";
|
||||
import { notFound } from "next/navigation";
|
||||
import { breadcrumbs, JsonLd } from "@/components/JsonLd";
|
||||
import { Mdx } from "@/components/Mdx";
|
||||
import { byline } from "@/lib/books";
|
||||
import { getBooks } from "@/lib/content";
|
||||
import { abs, site } from "@/lib/site";
|
||||
|
||||
export function generateStaticParams() {
|
||||
return getBooks().map((b) => ({ slug: b.slug }));
|
||||
}
|
||||
|
||||
export async function generateMetadata({
|
||||
params,
|
||||
}: PageProps<"/reading/[slug]">): Promise<Metadata> {
|
||||
const { slug } = await params;
|
||||
const book = getBooks().find((b) => b.slug === slug);
|
||||
if (!book) return {};
|
||||
const url = `/reading/${slug}`;
|
||||
const description = byline(book.data) || site.description;
|
||||
return {
|
||||
title: book.data.title,
|
||||
description,
|
||||
keywords: book.data.tags,
|
||||
alternates: { canonical: url },
|
||||
openGraph: {
|
||||
type: "article",
|
||||
url,
|
||||
title: book.data.title,
|
||||
description,
|
||||
siteName: site.name,
|
||||
locale: site.locale,
|
||||
},
|
||||
twitter: {
|
||||
card: "summary_large_image",
|
||||
title: book.data.title,
|
||||
description,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export default async function Book({ params }: PageProps<"/reading/[slug]">) {
|
||||
const { slug } = await params;
|
||||
const book = getBooks().find((b) => b.slug === slug);
|
||||
if (!book) notFound();
|
||||
const url = abs(`/reading/${slug}`);
|
||||
const item = {
|
||||
"@type": book.data.kind === "paper" ? "ScholarlyArticle" : "Book",
|
||||
name: book.data.title,
|
||||
url: book.data.url,
|
||||
author: book.data.authors?.map((name) => ({ "@type": "Person", name })),
|
||||
};
|
||||
const reviewLd = book.data.rating
|
||||
? {
|
||||
"@context": "https://schema.org",
|
||||
"@type": "Review",
|
||||
url,
|
||||
name: `Review: ${book.data.title}`,
|
||||
datePublished: book.data.dateFinished,
|
||||
author: { "@type": "Person", name: site.name, url: site.baseUrl },
|
||||
itemReviewed: item,
|
||||
reviewRating: {
|
||||
"@type": "Rating",
|
||||
ratingValue: book.data.rating,
|
||||
bestRating: 5,
|
||||
worstRating: 1,
|
||||
},
|
||||
}
|
||||
: null;
|
||||
return (
|
||||
<article className="flex flex-col gap-2">
|
||||
<JsonLd
|
||||
data={[
|
||||
...(reviewLd ? [reviewLd] : []),
|
||||
breadcrumbs([
|
||||
{ name: "Home", url: site.baseUrl },
|
||||
{ name: "Reading", url: abs("/reading") },
|
||||
{ name: book.data.title, url },
|
||||
]),
|
||||
]}
|
||||
/>
|
||||
<div className="flex flex-col">
|
||||
<h1 className="text-[36px] leading-[1.2] font-bold">
|
||||
{book.data.title}
|
||||
</h1>
|
||||
<p className="mt-2 text-[20px] leading-[30px] text-gray-400">
|
||||
{byline(book.data)}
|
||||
</p>
|
||||
</div>
|
||||
<div className="prose">
|
||||
<Mdx source={book.content} />
|
||||
</div>
|
||||
</article>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { Bookshelf } from "@/components/Bookshelf";
|
||||
import { getShelf } from "@/lib/books";
|
||||
|
||||
export default function ReadingLayout({ children }: LayoutProps<"/reading">) {
|
||||
return (
|
||||
<div className="flex flex-col gap-8">
|
||||
<Bookshelf books={getShelf()} />
|
||||
<hr />
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
import type { Metadata } from "next";
|
||||
import Link from "next/link";
|
||||
import { Mdx } from "@/components/Mdx";
|
||||
import { readLine } from "@/lib/books";
|
||||
import { coverExists, getBooks, spineFor, summarize } from "@/lib/content";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Reading",
|
||||
description: "Books and papers I have read, with ratings and notes.",
|
||||
alternates: { canonical: "/reading" },
|
||||
};
|
||||
|
||||
export default function ReadingIndex() {
|
||||
return (
|
||||
<div className="flex flex-col">
|
||||
<h1 className="sr-only">Reading</h1>
|
||||
{getBooks().map((b, i) => {
|
||||
const cover = coverExists(b.data.coverImage)
|
||||
? b.data.coverImage
|
||||
: undefined;
|
||||
const { spineColor, textColor } = spineFor(b.data.title);
|
||||
const summary = summarize(b.content);
|
||||
return (
|
||||
<div key={b.slug} className={i > 0 ? "mt-5" : undefined}>
|
||||
{i > 0 && <hr className="mb-3" />}
|
||||
<div className="flex gap-6">
|
||||
{cover ? (
|
||||
// biome-ignore lint/performance/noImgElement: small local cover
|
||||
<img
|
||||
src={cover}
|
||||
alt={b.data.title}
|
||||
className="h-[100px] border border-gray-200 sm:h-[140px] md:h-[160px]"
|
||||
style={{ width: "auto" }}
|
||||
/>
|
||||
) : (
|
||||
<div
|
||||
className="flex h-[100px] w-[68px] shrink-0 items-center border border-gray-200 p-2 text-xs font-bold sm:h-[140px] sm:w-24 md:h-[160px] md:w-28"
|
||||
style={{ backgroundColor: spineColor, color: textColor }}
|
||||
>
|
||||
{b.data.title}
|
||||
</div>
|
||||
)}
|
||||
<div className="flex min-w-0 flex-col">
|
||||
<Link
|
||||
href={`/reading/${b.slug}`}
|
||||
className="block hover:underline"
|
||||
>
|
||||
<h2 className="text-[20px] leading-6 font-bold">
|
||||
{b.data.title}
|
||||
</h2>
|
||||
</Link>
|
||||
{b.data.authors?.length ? (
|
||||
<p className="mt-2 text-[#999]">
|
||||
{b.data.authors.join(", ")}
|
||||
</p>
|
||||
) : null}
|
||||
<p className="mt-2 text-[#666]">{readLine(b.data)}</p>
|
||||
{summary && (
|
||||
<article className="prose mt-2">
|
||||
<Mdx source={summary} />
|
||||
</article>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import type { MetadataRoute } from "next";
|
||||
import { abs, site } from "@/lib/site";
|
||||
|
||||
export default function robots(): MetadataRoute.Robots {
|
||||
return {
|
||||
rules: [{ userAgent: "*", allow: "/" }],
|
||||
sitemap: abs("/sitemap.xml"),
|
||||
host: site.baseUrl,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
import { getFeedItems, xml } from "@/lib/feed";
|
||||
import { abs, site } from "@/lib/site";
|
||||
|
||||
export const dynamic = "force-static";
|
||||
|
||||
export async function GET() {
|
||||
const items = await getFeedItems();
|
||||
const body = `<?xml version="1.0" encoding="UTF-8"?>
|
||||
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
|
||||
<channel>
|
||||
<title>${xml(site.name)}</title>
|
||||
<link>${site.baseUrl}</link>
|
||||
<description>${xml(site.description)}</description>
|
||||
<language>en</language>
|
||||
<lastBuildDate>${(items[0]?.date ?? new Date()).toUTCString()}</lastBuildDate>
|
||||
<atom:link href="${abs("/rss.xml")}" rel="self" type="application/rss+xml"/>
|
||||
${items
|
||||
.map(
|
||||
(i) => `<item>
|
||||
<title>${xml(i.title)}</title>
|
||||
<link>${i.url}</link>
|
||||
<guid isPermaLink="true">${i.url}</guid>
|
||||
<pubDate>${i.date.toUTCString()}</pubDate>
|
||||
<description>${xml(i.description)}</description>
|
||||
${i.tags.map((t) => `<category>${xml(t)}</category>`).join("\n")}
|
||||
<content:encoded><![CDATA[${i.html.replace(/]]>/g, "]]]]><![CDATA[>")}]]></content:encoded>
|
||||
</item>`,
|
||||
)
|
||||
.join("\n")}
|
||||
</channel>
|
||||
</rss>
|
||||
`;
|
||||
return new Response(body, {
|
||||
headers: { "Content-Type": "application/rss+xml; charset=utf-8" },
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import type { MetadataRoute } from "next";
|
||||
import { getBooks, getWritings } from "@/lib/content";
|
||||
import { abs } from "@/lib/site";
|
||||
|
||||
export default function sitemap(): MetadataRoute.Sitemap {
|
||||
const posts = getWritings();
|
||||
const latest = posts[0]?.data.date;
|
||||
return [
|
||||
{ url: abs("/"), changeFrequency: "monthly", priority: 1 },
|
||||
{
|
||||
url: abs("/writing"),
|
||||
lastModified: latest ? new Date(String(latest)) : undefined,
|
||||
changeFrequency: "weekly",
|
||||
priority: 0.9,
|
||||
},
|
||||
{ url: abs("/reading"), changeFrequency: "monthly", priority: 0.6 },
|
||||
{ url: abs("/portfolio"), changeFrequency: "monthly", priority: 0.6 },
|
||||
...posts.map((p) => ({
|
||||
url: abs(`/writing/${p.slug}`),
|
||||
lastModified: new Date(String(p.data.date)),
|
||||
changeFrequency: "yearly" as const,
|
||||
priority: 0.8,
|
||||
})),
|
||||
...getBooks().map((b) => ({
|
||||
url: abs(`/reading/${b.slug}`),
|
||||
lastModified: b.data.dateFinished
|
||||
? new Date(b.data.dateFinished)
|
||||
: undefined,
|
||||
changeFrequency: "yearly" as const,
|
||||
priority: 0.4,
|
||||
})),
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import { getWritings } from "@/lib/content";
|
||||
import { ogContentType, ogImage, ogSize } from "@/lib/og";
|
||||
|
||||
export const size = ogSize;
|
||||
export const contentType = ogContentType;
|
||||
|
||||
export function generateStaticParams() {
|
||||
return getWritings().map((p) => ({ slug: p.slug }));
|
||||
}
|
||||
|
||||
export default async function Image({
|
||||
params,
|
||||
}: {
|
||||
params: Promise<{ slug: string }>;
|
||||
}) {
|
||||
const { slug } = await params;
|
||||
const post = getWritings().find((p) => p.slug === slug);
|
||||
return ogImage(post?.data.title ?? "Writing", "Writing");
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
import type { Metadata } from "next";
|
||||
import { notFound } from "next/navigation";
|
||||
import { breadcrumbs, JsonLd } from "@/components/JsonLd";
|
||||
import { Mdx } from "@/components/Mdx";
|
||||
import { formatDate, getWritings } from "@/lib/content";
|
||||
import { abs, site } from "@/lib/site";
|
||||
|
||||
export function generateStaticParams() {
|
||||
return getWritings().map((p) => ({ slug: p.slug }));
|
||||
}
|
||||
|
||||
export async function generateMetadata({
|
||||
params,
|
||||
}: PageProps<"/writing/[slug]">): Promise<Metadata> {
|
||||
const { slug } = await params;
|
||||
const post = getWritings().find((p) => p.slug === slug);
|
||||
if (!post) return {};
|
||||
const url = `/writing/${slug}`;
|
||||
const description = post.data.description || site.description;
|
||||
return {
|
||||
title: post.data.title,
|
||||
description,
|
||||
keywords: post.data.tags,
|
||||
alternates: { canonical: url },
|
||||
openGraph: {
|
||||
type: "article",
|
||||
url,
|
||||
title: post.data.title,
|
||||
description,
|
||||
siteName: site.name,
|
||||
locale: site.locale,
|
||||
publishedTime: String(post.data.date),
|
||||
modifiedTime: String(post.data.date),
|
||||
authors: [site.name],
|
||||
tags: post.data.tags,
|
||||
},
|
||||
twitter: {
|
||||
card: "summary_large_image",
|
||||
title: post.data.title,
|
||||
description,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export default async function Post({ params }: PageProps<"/writing/[slug]">) {
|
||||
const { slug } = await params;
|
||||
const post = getWritings().find((p) => p.slug === slug);
|
||||
if (!post) notFound();
|
||||
const url = abs(`/writing/${slug}`);
|
||||
const postLd = {
|
||||
"@context": "https://schema.org",
|
||||
"@type": "BlogPosting",
|
||||
headline: post.data.title,
|
||||
description: post.data.description || site.description,
|
||||
datePublished: String(post.data.date),
|
||||
dateModified: String(post.data.date),
|
||||
inLanguage: "en",
|
||||
keywords: post.data.tags?.join(", "),
|
||||
url,
|
||||
mainEntityOfPage: { "@type": "WebPage", "@id": url },
|
||||
image: abs(`/writing/${slug}/opengraph-image`),
|
||||
author: { "@type": "Person", name: site.name, url: site.baseUrl },
|
||||
publisher: { "@type": "Person", name: site.name, url: site.baseUrl },
|
||||
};
|
||||
return (
|
||||
<article className="flex flex-col gap-2">
|
||||
<JsonLd
|
||||
data={[
|
||||
postLd,
|
||||
breadcrumbs([
|
||||
{ name: "Home", url: site.baseUrl },
|
||||
{ name: "Writing", url: abs("/writing") },
|
||||
{ name: post.data.title, url },
|
||||
]),
|
||||
]}
|
||||
/>
|
||||
<h1 className="text-3xl font-bold md:text-4xl">{post.data.title}</h1>
|
||||
<time dateTime={String(post.data.date)} className="text-sm text-gray-500">
|
||||
{formatDate(String(post.data.date))}
|
||||
</time>
|
||||
<div className="prose">
|
||||
<Mdx source={post.content} />
|
||||
</div>
|
||||
</article>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
import type { Metadata } from "next";
|
||||
import Link from "next/link";
|
||||
import { formatDate, getWritings } from "@/lib/content";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Writing",
|
||||
description:
|
||||
"Essays and CTF writeups on software development, security, binary exploitation and Linux.",
|
||||
alternates: { canonical: "/writing" },
|
||||
};
|
||||
|
||||
export default function WritingIndex() {
|
||||
const posts = getWritings();
|
||||
return (
|
||||
<div className="flex flex-col gap-3">
|
||||
<h1 className="sr-only">Writing</h1>
|
||||
<hr />
|
||||
{posts.map((post) => (
|
||||
<div key={post.slug} className="flex flex-col gap-3">
|
||||
<div className="flex flex-col gap-1">
|
||||
<Link
|
||||
href={`/writing/${post.slug}`}
|
||||
className="text-blue-600 hover:underline"
|
||||
>
|
||||
{post.data.title}
|
||||
</Link>
|
||||
<span className="text-right text-sm text-gray-500">
|
||||
{formatDate(String(post.data.date))}
|
||||
</span>
|
||||
</div>
|
||||
<hr />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user