The best way to control Claude Code, Codex and more from any computer or phone

main
astro 137 lines 4.41 KB
Raw
1 ---
2 import FontPreloads from "../components/FontPreloads.astro";
3 import "../styles/tokens.css";
4 import "../styles/marketing.css";
5
6 import Nav from "../components/marketing/Nav.astro";
7 import Footer from "../components/marketing/Footer.astro";
8 import PostHog from "../components/analytics/PostHog.astro";
9 import ThemeProvider from "../components/ThemeProvider.astro";
10 import BrandIcons from "../brand/Icons.astro";
11 import StructuredData from "../components/StructuredData.astro";
12 import { socialOrigin } from "../social-origin";
13
14 interface Props {
15 title?: string;
16 description?: string;
17 /**
18 * Path to the page's OG image, relative to the site root. Defaults to
19 * the build-time generated card for the current page (slug derived from
20 * the URL pathname). The OG endpoint at `/og/[...slug].webp` produces
21 * these during `astro build`.
22 */
23 image?: string;
24 /**
25 * MDX/Markdown layouts receive their YAML frontmatter under this key
26 * rather than as flat props. We accept both shapes so an .astro page
27 * can pass `title=…` directly while an .mdx page's frontmatter just
28 * works.
29 */
30 frontmatter?: { title?: string; description?: string; image?: string };
31 }
32
33 const props = Astro.props;
34 const fm = props.frontmatter ?? {};
35 const title = props.title ?? fm.title ?? "Alchemy";
36 const description = props.description ?? fm.description;
37 const image = props.image ?? fm.image;
38
39 // Derive an OG image slug from the URL pathname when not explicitly set:
40 // "/" → /og/index.webp
41 // "/some/page" → /og/some/page.webp (currently unused, but future-proof)
42 const slug = (() => {
43 const p = Astro.url.pathname.replace(/^\/+|\/+$/g, "");
44 return p === "" ? "index" : p;
45 })();
46 const origin = socialOrigin(Astro.site, Astro.url);
47 const ogImage = new URL(image ?? `/og/${slug}.webp`, origin);
48 const ogUrl = new URL(Astro.url.pathname, origin);
49 const canonical = new URL(Astro.url.pathname, Astro.site);
50 ---
51
52 <!doctype html>
53 <html lang="en" data-theme="dark">
54 <head>
55 <meta charset="utf-8" />
56 <meta name="viewport" content="width=device-width, initial-scale=1" />
57 <FontPreloads />
58 {/* The site is dark-only: `data-theme="dark"` is set on <html> above
59 so it holds without JavaScript, and ThemeProvider adds the
60 color-scheme/theme-color metas. */}
61 <ThemeProvider />
62 <title>{title}</title>
63 {description && <meta name="description" content={description} />}
64 <link rel="canonical" href={canonical.href} />
65
66 <BrandIcons />
67
68 {/* Open Graph */}
69 <meta property="og:type" content="website" />
70 <meta property="og:site_name" content="alchemy" />
71 <meta property="og:title" content={title} />
72 {description && <meta property="og:description" content={description} />}
73 <meta property="og:url" content={ogUrl.href} />
74 <meta property="og:image" content={ogImage.href} />
75 <meta property="og:image:width" content="1200" />
76 <meta property="og:image:height" content="630" />
77
78 {/* Twitter / X */}
79 <meta name="twitter:card" content="summary_large_image" />
80 <meta name="twitter:site" content="@alchemy_run" />
81 <meta name="twitter:title" content={title} />
82 {description && <meta name="twitter:description" content={description} />}
83 <meta name="twitter:image" content={ogImage.href} />
84
85 <StructuredData />
86
87 <PostHog />
88 </head>
89 <body class="alc-root">
90 <header class="alc-marketing-header">
91 <Nav marketing />
92 </header>
93 <main>
94 <slot />
95 </main>
96 <Footer />
97 </body>
98 </html>
99
100 <style is:global>
101 html,
102 body {
103 margin: 0;
104 padding: 0;
105 background: var(--alc-bg);
106 color: var(--alc-fg-2);
107 font-family: var(--alc-font-sans);
108 -webkit-font-smoothing: antialiased;
109 overflow-x: clip;
110 }
111 /* In-page links glide, and land clear of the 64px sticky header.
112 tokens.css turns this off for reduced motion. */
113 html {
114 scroll-behavior: smooth;
115 scroll-padding-top: 80px;
116 }
117 a:focus-visible {
118 outline: 2px solid var(--alc-accent);
119 outline-offset: 2px;
120 }
121 .alc-marketing-header {
122 position: sticky;
123 top: 0;
124 z-index: 10;
125 height: 64px;
126 padding: 0 32px;
127 background: color-mix(in srgb, var(--alc-bg-nav) 92%, transparent);
128 backdrop-filter: saturate(140%) blur(8px);
129 border-bottom: 1px solid var(--alc-hairline);
130 }
131 @media (max-width: 640px) {
132 .alc-marketing-header { padding: 0 20px; }
133 }
134 @media (max-width: 480px) {
135 .alc-marketing-header { padding: 0 16px; }
136 }
137 </style>