---
import FontPreloads from "../components/FontPreloads.astro";
import "../styles/tokens.css";
import "../styles/marketing.css";
import Nav from "../components/marketing/Nav.astro";
import Footer from "../components/marketing/Footer.astro";
import PostHog from "../components/analytics/PostHog.astro";
import ThemeProvider from "../components/ThemeProvider.astro";
import BrandIcons from "../brand/Icons.astro";
import StructuredData from "../components/StructuredData.astro";
import { socialOrigin } from "../social-origin";
interface Props {
title?: string;
description?: string;
/**
* Path to the page's OG image, relative to the site root. Defaults to
* the build-time generated card for the current page (slug derived from
* the URL pathname). The OG endpoint at `/og/[...slug].webp` produces
* these during `astro build`.
*/
image?: string;
/**
* MDX/Markdown layouts receive their YAML frontmatter under this key
* rather than as flat props. We accept both shapes so an .astro page
* can pass `title=…` directly while an .mdx page's frontmatter just
* works.
*/
frontmatter?: { title?: string; description?: string; image?: string };
}
const props = Astro.props;
const fm = props.frontmatter ?? {};
const title = props.title ?? fm.title ?? "Alchemy";
const description = props.description ?? fm.description;
const image = props.image ?? fm.image;
// Derive an OG image slug from the URL pathname when not explicitly set:
// "/" → /og/index.webp
// "/some/page" → /og/some/page.webp (currently unused, but future-proof)
const slug = (() => {
const p = Astro.url.pathname.replace(/^\/+|\/+$/g, "");
return p === "" ? "index" : p;
})();
const origin = socialOrigin(Astro.site, Astro.url);
const ogImage = new URL(image ?? `/og/${slug}.webp`, origin);
const ogUrl = new URL(Astro.url.pathname, origin);
const canonical = new URL(Astro.url.pathname, Astro.site);
---
<!doctype html>
<html lang="en" data-theme="dark">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<FontPreloads />
{/* The site is dark-only: `data-theme="dark"` is set on <html> above
so it holds without JavaScript, and ThemeProvider adds the
color-scheme/theme-color metas. */}
<ThemeProvider />
<title>{title}</title>
{description && <meta name="description" content={description} />}
<link rel="canonical" href={canonical.href} />
<BrandIcons />
{/* Open Graph */}
<meta property="og:type" content="website" />
<meta property="og:site_name" content="alchemy" />
<meta property="og:title" content={title} />
{description && <meta property="og:description" content={description} />}
<meta property="og:url" content={ogUrl.href} />
<meta property="og:image" content={ogImage.href} />
<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="630" />
{/* Twitter / X */}
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:site" content="@alchemy_run" />
<meta name="twitter:title" content={title} />
{description && <meta name="twitter:description" content={description} />}
<meta name="twitter:image" content={ogImage.href} />
<StructuredData />
<PostHog />
</head>
<body class="alc-root">
<header class="alc-marketing-header">
<Nav marketing />
</header>
<main>
<slot />
</main>
<Footer />
</body>
</html>
<style is:global>
html,
body {
margin: 0;
padding: 0;
background: var(--alc-bg);
color: var(--alc-fg-2);
font-family: var(--alc-font-sans);
-webkit-font-smoothing: antialiased;
overflow-x: clip;
}
/* In-page links glide, and land clear of the 64px sticky header.
tokens.css turns this off for reduced motion. */
html {
scroll-behavior: smooth;
scroll-padding-top: 80px;
}
a:focus-visible {
outline: 2px solid var(--alc-accent);
outline-offset: 2px;
}
.alc-marketing-header {
position: sticky;
top: 0;
z-index: 10;
height: 64px;
padding: 0 32px;
background: color-mix(in srgb, var(--alc-bg-nav) 92%, transparent);
backdrop-filter: saturate(140%) blur(8px);
border-bottom: 1px solid var(--alc-hairline);
}
@media (max-width: 640px) {
.alc-marketing-header { padding: 0 20px; }
}
@media (max-width: 480px) {
.alc-marketing-header { padding: 0 16px; }
}
</style>