mirror of
https://github.com/andwati/andwati.com.git
synced 2026-11-28 03:18:46 +00:00
Replaces the legacy Zola script, which was hard-coded to the retired "CASE FILE" branding, with scripts/generate-og-images.astro-site.mjs built on the new design system's dark palette + Fraunces/JetBrains Mono. Base.astro now renders og:image/twitter:image from a per-page ogImage prop, wired into the writings and bookshelf detail pages. Uses static-weight Fraunces/Newsreader font packages rather than the variable fonts the site ships elsewhere, since satori's opentype.js parser throws on their fvar table.
173 lines
6.0 KiB
Plaintext
173 lines
6.0 KiB
Plaintext
---
|
|
import "@fontsource-variable/fraunces";
|
|
import "@fontsource-variable/newsreader";
|
|
import "@fontsource/jetbrains-mono";
|
|
import "../styles/global.css";
|
|
import { copyrightYearRange } from "../lib/copyright-year";
|
|
import { siteConfig } from "../site.config";
|
|
|
|
interface Props {
|
|
title: string;
|
|
description?: string;
|
|
/** Widens .container for dashboard-style layouts (currently just the homepage). */
|
|
wide?: boolean;
|
|
/** Site-root-relative path to a per-page OG image, e.g. /images/og/writings/foo.png */
|
|
ogImage?: string;
|
|
}
|
|
const { title, description, wide = false, ogImage } = Astro.props;
|
|
const metaDescription = description ?? siteConfig.description;
|
|
const currentPath = Astro.url.pathname;
|
|
const copyrightRange = await copyrightYearRange();
|
|
const pageTitle = `${title} — ${siteConfig.title}`;
|
|
const ogImageUrl = new URL(ogImage ?? "/favicon.svg", siteConfig.baseUrl).href;
|
|
---
|
|
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
<title>{pageTitle}</title>
|
|
<meta name="description" content={metaDescription} />
|
|
<link rel="alternate" type="application/rss+xml" title={siteConfig.title} href="/rss.xml" />
|
|
<link rel="alternate" type="application/feed+json" title={siteConfig.title} href="/feed.json" />
|
|
<link rel="webmention" href="https://webmention.io/andwati.com/webmention" />
|
|
<meta property="og:type" content="website" />
|
|
<meta property="og:title" content={pageTitle} />
|
|
<meta property="og:description" content={metaDescription} />
|
|
<meta property="og:url" content={Astro.url.href} />
|
|
<meta property="og:image" content={ogImageUrl} />
|
|
<meta name="twitter:card" content="summary_large_image" />
|
|
<meta name="twitter:title" content={pageTitle} />
|
|
<meta name="twitter:description" content={metaDescription} />
|
|
<meta name="twitter:image" content={ogImageUrl} />
|
|
<script is:inline>
|
|
// Runs before paint to avoid a flash of the wrong theme.
|
|
(function () {
|
|
try {
|
|
var stored = localStorage.getItem("theme");
|
|
if (stored === "light" || stored === "dark") {
|
|
document.documentElement.setAttribute("data-theme", stored);
|
|
}
|
|
} catch {}
|
|
})();
|
|
</script>
|
|
<style>
|
|
header {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
flex-wrap: wrap;
|
|
gap: var(--space-4) var(--space-6);
|
|
padding-block: var(--space-6);
|
|
}
|
|
.site-name {
|
|
font-family: var(--font-mono);
|
|
font-size: var(--font-size-sm);
|
|
letter-spacing: 0.08em;
|
|
text-decoration: none;
|
|
color: var(--text);
|
|
}
|
|
nav {
|
|
display: flex;
|
|
align-items: center;
|
|
flex-wrap: wrap;
|
|
gap: var(--space-5);
|
|
}
|
|
nav a {
|
|
font-family: var(--font-mono);
|
|
font-size: var(--font-size-sm);
|
|
letter-spacing: 0.06em;
|
|
text-transform: uppercase;
|
|
text-decoration: none;
|
|
color: var(--text-muted);
|
|
transition: color 0.2s var(--ease-out);
|
|
}
|
|
nav a:hover,
|
|
nav a[aria-current="page"] {
|
|
color: var(--accent);
|
|
}
|
|
#theme-toggle {
|
|
background: none;
|
|
border: 1px solid var(--border);
|
|
border-radius: var(--radius-sm);
|
|
color: var(--text-muted);
|
|
width: 2rem;
|
|
height: 2rem;
|
|
display: inline-flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
cursor: pointer;
|
|
font-family: var(--font-mono);
|
|
font-size: 0.9rem;
|
|
transition:
|
|
border-color 0.2s var(--ease-out),
|
|
color 0.2s var(--ease-out);
|
|
}
|
|
#theme-toggle:hover {
|
|
border-color: var(--accent);
|
|
color: var(--accent);
|
|
}
|
|
main {
|
|
min-height: 60vh;
|
|
}
|
|
footer {
|
|
margin-top: var(--space-8);
|
|
padding-block: var(--space-6);
|
|
border-top: 1px solid var(--border);
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
flex-wrap: wrap;
|
|
gap: var(--space-4);
|
|
}
|
|
footer nav {
|
|
gap: var(--space-4);
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class:list={["container", { "container--wide": wide }]}>
|
|
<header>
|
|
<a class="site-name" href="/">{siteConfig.author.toUpperCase()}</a>
|
|
<nav aria-label="Primary">
|
|
{
|
|
siteConfig.nav.map((item) => (
|
|
<a href={item.url} aria-current={currentPath.startsWith(item.url) ? "page" : undefined}>
|
|
{item.name}
|
|
</a>
|
|
))
|
|
}
|
|
<a href="/tags/" aria-current={currentPath.startsWith("/tags/") ? "page" : undefined}>Tags</a>
|
|
<a href="/search/" aria-current={currentPath.startsWith("/search/") ? "page" : undefined}>Search</a>
|
|
<button id="theme-toggle" type="button" aria-label="Toggle color theme">◐</button>
|
|
</nav>
|
|
</header>
|
|
<main>
|
|
<slot />
|
|
</main>
|
|
<footer>
|
|
<p class="meta">© {copyrightRange} {siteConfig.author}</p>
|
|
<nav aria-label="Social">
|
|
<a href={siteConfig.social.github} class="meta" rel="me noopener" target="_blank">GitHub</a>
|
|
<a href={siteConfig.social.twitter} class="meta" rel="me noopener" target="_blank">Twitter</a>
|
|
<a href={siteConfig.social.youtube} class="meta" rel="me noopener" target="_blank">YouTube</a>
|
|
<a href={`mailto:${siteConfig.social.email}`} class="meta">Email</a>
|
|
</nav>
|
|
</footer>
|
|
</div>
|
|
<script is:inline>
|
|
document.getElementById("theme-toggle").addEventListener("click", function () {
|
|
var root = document.documentElement;
|
|
var current =
|
|
root.getAttribute("data-theme") ||
|
|
(window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light");
|
|
var next = current === "dark" ? "light" : "dark";
|
|
root.setAttribute("data-theme", next);
|
|
try {
|
|
localStorage.setItem("theme", next);
|
|
} catch {}
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|