Skip to content

Commit 7196305

Browse files
codercatdevclaude
andcommitted
feat: scaffold Astro 7 site on Cloudflare Workers
Adds apps/site (@codingcatdev/site) as a new workspace package alongside the existing Next app, which keeps building until the dashboard is ported. Added rather than replacing apps/web because the pre-Next Astro app (branch `dev`) was also named @codingcatdev/web — replacing in place would make every `pnpm --filter` and the git history ambiguous. - output: "server" + @astrojs/cloudflare 14 (SSR on Workers) - wrangler.jsonc with dev/production envs; D1 binding deliberately omitted until the codingcat.dev Cloudflare account is available - rawFonts() Vite plugin harvested verbatim from dev:apps/web/astro.config.mjs (Workers has no filesystem; needed for OG image generation) - Dropped that config's Vite alias/dedupe/optimizeDeps block — it existed to fight @sanity/visual-editing under Astro 6 and is obsoleted by @sanity/visual-editing-standalone - Node pinned to >=22.12 (.nvmrc + engines), required by sanity 6 / @sanity/ui 4 - baseline/ holds pre-migration production sitemap + RSS snapshots for post-cutover parity diffing (472 URLs, 50 items per feed) Verified: pnpm build succeeds and wrangler dev serves SSR HTML via workerd. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HZ4S1uTJwFdbv3A6PHWfw2
1 parent 648523f commit 7196305

18 files changed

Lines changed: 13247 additions & 2001 deletions

‎.nvmrc‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
22.23.2

‎apps/site/.dev.vars.example‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Local secrets for `wrangler dev` / platformProxy. Copy to .dev.vars (gitignored).
2+
SANITY_API_READ_TOKEN=

‎apps/site/astro.config.mjs‎

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import { defineConfig } from "astro/config";
2+
import cloudflare from "@astrojs/cloudflare";
3+
import react from "@astrojs/react";
4+
import tailwindcss from "@tailwindcss/vite";
5+
import fs from "node:fs";
6+
import path from "node:path";
7+
8+
/**
9+
* Inline font files as Uint8Array at build time.
10+
* Required for OG image generation on Workers, which has no filesystem.
11+
* Harvested verbatim from the pre-Next Astro app (branch `dev`,
12+
* apps/web/astro.config.mjs) — it is the payoff of a long debugging arc
13+
* around Satori/workers-og and should not be re-derived.
14+
*/
15+
function rawFonts(extensions) {
16+
return {
17+
name: "vite-plugin-raw-fonts",
18+
enforce: "pre",
19+
resolveId(id, importer) {
20+
if (extensions.some((ext) => id.includes(ext))) {
21+
if (id.startsWith(".")) {
22+
return path.resolve(path.dirname(importer), id);
23+
}
24+
return id;
25+
}
26+
},
27+
load(id) {
28+
if (extensions.some((ext) => id.includes(ext))) {
29+
const buffer = fs.readFileSync(id);
30+
return `export default new Uint8Array([${Array.from(buffer).join(",")}]);`;
31+
}
32+
},
33+
};
34+
}
35+
36+
export default defineConfig({
37+
site: process.env.SITE_URL ?? "https://codingcat.dev",
38+
output: "server",
39+
adapter: cloudflare({
40+
// Images are Sanity CDN URLs already transformed by @sanity/image-url;
41+
// do not route them through Cloudflare Images.
42+
imageService: "passthrough",
43+
platformProxy: { enabled: true },
44+
}),
45+
integrations: [react()],
46+
redirects: {
47+
"/blog/page": "/blog",
48+
"/podcasts/page": "/podcasts",
49+
"/authors/page": "/authors",
50+
"/guests/page": "/guests",
51+
"/sponsors/page": "/sponsors",
52+
},
53+
vite: {
54+
plugins: [tailwindcss(), rawFonts([".ttf", ".otf"])],
55+
assetsInclude: ["**/*.wasm"],
56+
},
57+
});

‎apps/site/baseline/blog_rss.json‎

Lines changed: 663 additions & 0 deletions
Large diffs are not rendered by default.

‎apps/site/baseline/blog_rss.xml‎

Lines changed: 518 additions & 0 deletions
Large diffs are not rendered by default.

‎apps/site/baseline/podcasts_rss.json‎

Lines changed: 664 additions & 0 deletions
Large diffs are not rendered by default.

‎apps/site/baseline/podcasts_rss.xml‎

Lines changed: 1418 additions & 0 deletions
Large diffs are not rendered by default.

‎apps/site/baseline/robots.txt‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
User-Agent: *
2+
Allow: /
3+
Disallow: /api/
4+
Disallow: /dashboard/
5+
6+
Host: https://codingcat.dev
7+
Sitemap: https://codingcat.dev/sitemap.xml

0 commit comments

Comments
 (0)