Skip to content

Commit bece6bc

Browse files
codercatdevMiriadcursoragentclaude
authored
Release: Astro 7 SSR Cloudflare migration, Sanity semantic search, SearchModal & syndication (#686)
* feat: Astro 7 SSR Cloudflare migration, Sanity semantic search, SearchModal & syndication (#685) * fix: stronger black bg enforcement in Gemini image prompts V5b showed 2/4 infographic frames with gray/off-white backgrounds despite the color rule saying 'Use ONLY black'. Restructured as numbered rules with explicit rejection language. Background rule is now #1 priority. * temp * refactor: consolidate monorepo with Next.js in apps/web and Sanity in apps/sanity Replace the Astro apps/web on dev with main's Next.js app, strip the embedded Studio route, wire typegen to apps/sanity's schema extract, and trim CI to Sanity Studio deploys only (Vercel handles apps/web). Co-authored-by: Cursor <cursoragent@cursor.com> * fix: update route type imports and adjust draft mode client configuration - Changed the import path for route types in next-env.d.ts to point to the development directory. - Modified the client configuration in route.tsx to disable CDN usage for draft mode, ensuring accurate content retrieval during editing. * feat: update Sanity dependencies and enhance draft mode functionality - Upgraded Sanity-related packages to their latest versions for improved performance and features. - Implemented dynamic fetching options in various components to support draft mode, enhancing content visibility during editing. - Adjusted the sitemap and page components to utilize the new fetching methods, ensuring accurate data retrieval based on the selected perspective. - Introduced caching mechanisms for improved efficiency in data fetching. * refactor: replace deprecated sanity-typegen.json with inline typegen configuration - Removed the obsolete sanity-typegen.json file. - Integrated typegen configuration directly into the Sanity CLI setup, ensuring schema extraction and type generation are streamlined within the cliConfig. * chore: update dependencies for React and Next.js - Upgraded React and React DOM to version 19.2.6 for improved performance and compatibility. - Updated Next.js to version 16.2.6 to leverage the latest features and enhancements. * chore: update package dependencies and enhance sitemap functionality - Upgraded pnpm to version 10.34.1 for improved package management. - Added new skills to skills-lock.json for better content modeling and SEO practices. - Introduced schema-dts version 2.0.0 to enhance TypeScript support. - Updated sitemap generation to utilize SITE_URL for dynamic URL handling across various components. - Enhanced metadata generation for authors, guests, podcasts, posts, and sponsors to include structured data for better SEO. * fix: resolve Cache Components prerender errors blocking production build Dashboard pages are auth-gated and render live data per request, but were being prerendered into the static shell, tripping Cache Components rules (Date.now in lib/config, uncached Sanity fetches outside Suspense). - Refactor dashboard pages to the three-layer pattern: static shell plus a Suspense-wrapped child that calls connection() before fetching (config, content, pipeline, review, review/[id], sponsors, videos) - Wrap the live time-reading components on the dashboard index in Suspense - Wrap NavHeaderSlot and Footer in the (main) layout in Suspense so the one dynamic route (/podcast/preview/[token]) can produce a static shell - Make /api/youtube/rss.xml dynamic via connection() (external fetch + Date) Co-authored-by: Cursor <cursoragent@cursor.com> * refactor: update RSS feed generation methods for podcasts and blogs - Replaced the deprecated `buildFeed` and `buildPodcastFeed` functions with `getFeedJson` and `getPodcastFeedXml` for improved performance and clarity. - Streamlined the fetching of feed data to reduce payload size and enhance caching efficiency. - Updated related route handlers to utilize the new feed generation methods, ensuring consistent data retrieval across JSON and XML feeds. * refactor: update cache usage in live data fetching functions - Changed cache directive from "use cache" to "use cache: remote" in the `sanityFetchStaticParams` and `sanityFetchMetadata` functions to clarify the caching strategy. - This update enhances the understanding of data fetching behavior in relation to remote caching. * refactor: enhance data fetching and caching strategies in dashboard components - Updated dashboard components to improve data fetching efficiency by implementing a more structured caching approach. - Refactored components to better utilize Suspense for dynamic data rendering, ensuring a smoother user experience. - Adjusted the integration of live data fetching methods to align with recent caching updates, enhancing overall performance. * 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 * chore: upgrade Sanity Studio to v6.9.2 sanity 5.17.1 -> 6.9.2, @sanity/ui 3 -> 4, @sanity/vision 6.9.2, @sanity/icons 3 -> 5, @sanity/assist 6.1.19, @sanity/code-input 7.3.5, sanity-plugin-media 4 -> 6, @portabletext/react 6 -> 7 (matching sanity@6.9.2's own dep so toPlainText resolves a single copy). Four blockers surfaced during the upgrade: 1. @sanity/icons v5 removed every icon from the root entry (they remain as `declare const X: never` with a deprecation naming the fix). All eight imports moved to subpaths, e.g. @sanity/icons/User. 2. The workspace override "@portabletext/sanity-bridge": "^1.2.14" starved sanity@6.9.2, which needs ^3.2.5 for getSanitySubSchema. Removed; pnpm now resolves 1.2.14 for apps/web's sanity@5 and 3.2.5 for the Studio. 3. @codingcatdev/sanity-plugin-podcast-rss could not simply be dropped: schemas/documents/podcast.ts declares a field of type "podcastRssEpisode", which only that plugin registers, so removing it broke schema extraction. Vendored into plugins/podcast-rss/ (see its README) migrated to @sanity/ui v4 — Menu/MenuButton/MenuItem from the /menu subpath, `space` -> `gap` — and off xml2js onto the native DOMParser, since xml2js only resolved via a Vite polyfill that Vite 8 no longer provides. Field shapes are kept byte-identical so existing podcast documents are unaffected. 4. @sanity/ui v4: Stack `space` -> `gap` (2 call sites) and Avatar `alt` -> `title`. Also fixed pre-existing issues the upgrade exposed: react-inlinesvg was imported by the Studio but declared only in apps/web; SharePreviewActionButton imported five symbols from "@/sanity/lib/api" despite the Studio tsconfig having no such path alias (all unused); CodeSandboxPreview imported an unused RenderPreviewCallbackProps. Removed the stray unused podcast-rss dependency from apps/web. tsconfig target ES2020 -> ES2022 for Array.prototype.at. Verified: builds, typechecks clean, dev server boots on Vite 8.2.1, and schema extract succeeds with zero types removed (two added by sanity-plugin-media v6). Still needs a human click-test of markdown paste in the Portable Text editor. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HZ4S1uTJwFdbv3A6PHWfw2 * ci: add build/lint/typecheck gate and repo agent docs The repo had no CI at all — no lint, typecheck, build, or test ran on any push. Two latent breakages had accumulated unnoticed as a result: - apps/web/biome.json is invalid for Biome 2 (`jsxRuntime: "automatic"` is not an accepted value), so `pnpm lint` there has been failing on a config error rather than linting anything. Left as-is since apps/web is being retired; apps/site gets a corrected Biome 2 config (`assist.actions.source`, `files.includes` with negations, `jsxRuntime: "transparent"`). - apps/sanity/extract.json can silently drift from the schema, which is how three divergent copies accumulated. CI now re-runs the extract and fails if the result differs from what is committed. ci.yml runs lint + typecheck + build for the site, typecheck + build for the Studio, and the extract drift check. Uses node-version-file: .nvmrc rather than a bare "22", which is what actually enforces the >=22.12 floor that sanity 6 and @sanity/ui 4 require; deploy.yml switched to the same. deploy.yml also gains a paths filter so site-only changes stop redeploying the Studio on every push. Adds a root CLAUDE.md (the repo had no root docs) recording the package layout, the in-flight migration, where the vendored Sanity skills live, and the conventions that have already caused real bugs here — no getStaticPaths under output: "server", GROQ must live in .ts files for TypeGen, never read secrets from import.meta.env, bindings are not inherited into env.production, and stegaClean anything bound to an attribute or feed. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HZ4S1uTJwFdbv3A6PHWfw2 * feat: Astro Sanity data layer and consolidated typegen Adds apps/site/src/lib/sanity/* and converts all 26 GROQ queries from `groq` tagged templates to `defineQuery`, so generated types flow to call sites and the `as` casts the Next app needed are gone. Two assumptions from the migration plan turned out to be wrong, and were verified empirically before committing to a layout: - TypeGen DOES resolve const interpolation inside defineQuery, including across module boundaries. The shared projection partials (baseFieldsNoContent, contentFields, ...) are therefore kept in queries/shared.ts rather than being inlined into every query. - @astrojs/cloudflare v14 reduced `Runtime` to `{ cfContext }` and marks `locals.runtime` a deprecated getter. Bindings and vars are read via `import { env } from "cloudflare:workers"` instead — which is also what the pre-Next Astro app did. Three bugs in the harvested fetch layer (dev:apps/web/src/utils/sanity.ts) are fixed rather than carried over: - `useCdn: false` on the base client. Under Next this was masked by ISR; under pure SSR it would put every anonymous page view on the uncached live API. Published reads now use the CDN, which Sanity purges on publish. - stega configured on the base client and suppressed per-request. Inverted: off by default, on only in previewClient, so RSS/sitemap/OG/JSON-LD cannot leak zero-width characters into hrefs and XML. - read token sourced from `import.meta.env`, which Vite inlines into the server bundle — that would bake the token into the deployed Worker script. Now read per-request from the runtime env, and preview fails closed when absent. Config is resolved per-request because wrangler `vars` reach the Worker through the runtime env, not `import.meta.env`. apiVersion is pinned to 2025-09-30 to match apps/sanity/sanity.config.ts; the old Astro app used 2026-03-17, a silent divergence between what authors preview in Vision and what the site renders. Middleware builds the request context onto `locals.sanity` and sets `no-store, private` + `noindex` on preview responses, so a page containing unpublished drafts cannot be written to the edge cache. Queries that took a $type parameter (docCount, rssQuery) are split per type — a parameterised _type widens the generated result to a union of every document type. urlForImage is consolidated to one implementation keeping the `.auto("format")` behaviour; resolveHref now covers the whole public route map instead of only "post". Typegen moves entirely into apps/sanity: apps/web/sanity.cli.ts is deleted along with its typegen/predev/prebuild scripts and its `sanity` devDependency, and the two stale schema copies (apps/web/sanity/extract.json, apps/web/schema.json) are removed. CI regenerates types before typechecking and fails if the committed extract.json has drifted. Verified end to end: `wrangler dev` serves the home page with real Sanity content from the dev dataset, typechecking clean with no casts. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HZ4S1uTJwFdbv3A6PHWfw2 * feat: Astro layout, components, and listing routes Ports the shared layout and every listing route from the Next app, with production parity as the target rather than a redesign. Design tokens come from apps/web/app/globals.css — the live production stylesheet — not the pre-Next Astro app on `dev`, which carried a different, never-shipped dark-first token set that would have been a visual regression at cutover. Dashboard-only tokens are dropped. Routes: /, /blog + /blog/page/[num], /podcasts + /podcasts/page/[num], /authors|guests|sponsors/page/[num], and 404. Pagination is a runtime bounds check on Astro.params — there is no getStaticPaths — rejecting anything that is not a bare positive integer so one page cannot be served under unlimited URLs, and 302-ing out-of-range requests to the last page. Redirects mirror production exactly: /authors, /guests and /sponsors redirect to /page/1, and the bare /{base}/page stubs go to /page/1 (not to the section index, which is what the scaffold assumed). Components ship no framework JS. next-themes becomes an inline script, the Radix Sheet becomes a details-free drawer, react-icons paths are inlined, and usePathname-based active-nav detection is resolved at render time. A blog listing page now carries 1.4 KB of inline script and no external bundle. Two fixes over the Next behaviour: - Canonical and og:url were derived from build-time `Astro.site`, but SITE_URL is a per-environment wrangler var and CI builds once for both Workers — the dev Worker would have claimed production URLs. Resolved per request in middleware as `Astro.locals.siteUrl`. - JSON-LD advertised an Organization logo at /icon.svg, which 404s in production because Next serves that file at a hashed metadata URL. The asset is now in public/ and the URL resolves. The home page's two-column grids drop the `slice(0, length / 2)` index arithmetic, which silently dropped the last item on an odd count. Verified against a real Worker under `wrangler dev`: all routes 200, /blog/page/abc 404s, /blog/page/99999 302s to the last page, no stega leakage into attributes, and .assetsignore keeps _worker.js unserved. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HZ4S1uTJwFdbv3A6PHWfw2 * feat: portable text renderers and content detail routes Twelve Astro renderers for the custom block types, plus the detail routes that consume them: /post/[slug], /podcast/[slug], /author/[slug], /guest/[slug], /sponsor/[slug], and the /[slug] catch-all for page documents. The pre-Next Astro app rendered Portable Text with no component map at all, so every custom block rendered as nothing. This is the piece that was genuinely missing rather than portable. astro-portabletext uses SINGULAR `type` / `block` / `mark` keys where @portabletext/react uses `types` / `marks`, and mark components receive the mark definition on `node.markDef` rather than on the node. Both fail silently — the components simply never run — so both are called out at the definition sites. Dependencies dropped, not ported: - react-syntax-highlighter and the hand-maintained Prism language list become Astro's bundled Shiki, highlighting at render time. Language ids are normalised through an allowlist first: `@sanity/code-input` does not constrain the field, and one live document carries `language: "Zanzibar"`, which Shiki throws on. The allowlist is typed as a literal union so a typo in it is a compile error rather than a runtime 500. - react-markdown per table cell. No table block exists in production — every cell in the dataset is null — so it was never exercised. Cells render as text. - embla-carousel for YouTube shorts becomes a scroll-snap row. - react-twitter-embed becomes the official blockquote markup, with widgets.js loaded only when a page actually contains a post. It now degrades to a readable link when the script is blocked. - react-icons for the 20 social platforms: paths inlined. Fixes carried in: - CodePen and CodeSandbox URL parsing was positional destructuring and an unguarded double `.at(-1)`; a malformed URL threw at render. Both validate now. - Tables get a header row. The Next version emitted every row as `<td>` in a bare `<tbody>`, leaving no column headers for screen readers. - Sanity's file-asset URL for cover video read NEXT_PUBLIC_* env at module scope, which does not exist on Workers; it uses the per-request config. - Socials rendered an empty clickable link for any key without an icon (`email`, `polywork`); unknown keys are skipped and both now have one. Podcast episodes play through a native audio element for now — the persistent floating player is a React island and lands with the rest of the islands. Verified against a real Worker: code, quote, image, htmlBlock and twitter blocks all render from live dev-dataset documents, Shiki emits dual-theme output with the dark variant activated, and every detail route 200s while unknown slugs 404. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HZ4S1uTJwFdbv3A6PHWfw2 * feat: feeds, sitemap, and robots Ports /blog/rss.{xml,json}, /podcasts/rss.{xml,json}, /sitemap.xml and /robots.txt, all serialized by hand — the `feed` package reaches for Node built-ins that are awkward on workerd, and these are fixed shapes. Verified against the pre-migration production snapshots in apps/site/baseline by running the Worker with the production config: - sitemap.xml: byte-identical, all 472 URLs - podcasts/rss.xml: byte-identical apart from timestamps - blog/rss.xml: identical apart from <generator>, which no longer names a library we do not use - both JSON feeds: same key order, same 50 ids in the same order - robots.txt: identical GUID stability was the thing to get right and it holds: all 100 feed items keep their Sanity _id, in order. A changed podcast GUID would re-publish the entire back catalogue to Apple and Spotify. Two live bugs fixed rather than reproduced: - The production blog feed is not well-formed XML. The `feed` library emits unescaped `&` in enclosure URLs, so `ET.parse` rejects blog_rss.xml at line 25. Ours escapes them. - Feed bodies were serialized by `toHTML` with no component map, so internal links rendered as `<span class="unknown__pt__mark__internalLink">` and code, images, tables and embeds were dropped or stubbed. There is now a map; links resolve to absolute URLs so they work inside a reader. Deliberately reproduced, including the odd parts: `image/jpg` rather than `image/jpeg` for enclosures, one `<author>` element per author, and `<description>` omitted entirely when the excerpt is empty. Churning those would change what existing subscribers see for no benefit. robots.txt now serves `Disallow: /` outside production, so the dev Worker and preview aliases cannot be indexed alongside the real site. Also fixes a deployment trap found while verifying this. The Cloudflare adapter flattens wrangler.jsonc at BUILD time and writes .wrangler/deploy/config.json, which redirects wrangler away from the source config — `env.production` is dropped, keeping only its name. So `wrangler deploy --env production` on a default build would have shipped the dev dataset under the dev worker name. The environment is selected by `CLOUDFLARE_ENV` at build time; added a `build:production` script and documented it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HZ4S1uTJwFdbv3A6PHWfw2 * feat: OG image generation on Workers Four Satori-backed endpoints — /api/og/{default,blog,podcast,person}.png — recovered from the pre-Next Astro app along with the two Inter TTFs and the rawFonts Vite plugin that inlines them as Uint8Array (Workers has no filesystem for Satori to read from). The load-bearing part of that recovery is its workaround, kept verbatim with its explanation: workers-og parses HTML with HTMLRewriter, which corrupts the HTML-to-VDOM conversion on Workers, so these build React element objects and hand them to ImageResponse directly. Wired in as a FALLBACK, not a replacement. Where a document has a cover image the card is still that image, byte-for-byte what the Next app served. Documents without one previously emitted no og:image at all; those now get a generated card. The home page and section indexes get one too. Verified on real workerd under `wrangler dev`, not `astro dev` — all four endpoints return valid 1200x630 PNGs, and the rendered images were inspected rather than just status-checked. That caught the one visual defect: the recovered logo used a cat emoji, and Satori renders only glyphs present in the fonts it is given, so it came out as a tofu box on every card. Replaced with a monogram tile in the brand gradient. Brand tokens are literal hex rather than the CSS custom properties the rest of the site uses: Satori resolves neither var() nor oklch(). Font imports are now typed via a `*.ttf` module declaration, since Astro's own asset typings declare them as URL strings — the opposite of what the rawFonts plugin actually returns. That removes the `@ts-ignore` pair and the `as any` in loadFonts. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HZ4S1uTJwFdbv3A6PHWfw2 * feat: Astro SSR parity, Sanity semantic search, SearchModal, and syndication * ci: add cf-typegen step and automatic PR preview comment with Cloudflare preview URL * fix(ci): fix yaml indentation and use echo for pr comment markdown * fix(ci): fix hardcoded font paths in test mocks and enhance pr preview url reporting * fix(ci): fix yaml indentation and clean up secrets syntax in workflows * feat(sanity): dedicated studio dataset workspaces and deploy workflow environment passing --------- Co-authored-by: Miriad <miriad@miriad.systems> Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix(sanity): refresh extract.json cleanly after merge --------- Co-authored-by: Miriad <miriad@miriad.systems> Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 648523f commit bece6bc

189 files changed

Lines changed: 25998 additions & 4312 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/ci.yml‎

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [dev, main]
7+
8+
concurrency:
9+
group: ci-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
verify:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- uses: pnpm/action-setup@v4
19+
20+
# node-version-file (not a bare "22") is what actually enforces the
21+
# >=22.12 floor required by sanity 6 / @sanity/ui 4.
22+
- uses: actions/setup-node@v4
23+
with:
24+
node-version-file: ".nvmrc"
25+
cache: "pnpm"
26+
27+
- name: Install dependencies
28+
run: pnpm install --frozen-lockfile
29+
30+
# Generates apps/sanity/extract.json and the site's types.gen.ts, both of
31+
# which are derived artifacts and therefore gitignored. Runs before
32+
# typecheck because the site imports the generated types.
33+
- name: Typegen (Sanity)
34+
run: pnpm typegen
35+
env:
36+
SANITY_STUDIO_PROJECT_ID: hfh83o0w
37+
SANITY_STUDIO_DATASET: production
38+
39+
- name: Typegen (Cloudflare)
40+
run: pnpm --filter @codingcatdev/site cf-typegen
41+
42+
- name: Lint (site)
43+
run: pnpm --filter @codingcatdev/site lint
44+
45+
- name: Typecheck (site)
46+
run: pnpm --filter @codingcatdev/site typecheck
47+
48+
- name: Typecheck (studio)
49+
run: pnpm --filter @codingcatdev/sanity exec tsc --noEmit
50+
51+
- name: Build site
52+
run: pnpm --filter @codingcatdev/site build
53+
54+
- name: Build studio
55+
run: pnpm --filter @codingcatdev/sanity build
56+
env:
57+
SANITY_STUDIO_PROJECT_ID: hfh83o0w
58+
SANITY_STUDIO_DATASET: production
59+
60+
- name: Run E2E Tests
61+
run: pnpm --filter @codingcatdev/site test:e2e
62+
63+
# extract.json is committed and is the single source of truth for typegen.
64+
# The Typegen step above regenerates it; if that changed the file, the
65+
# commit is stale. This is what stopped three divergent copies before.
66+
- name: Verify extract.json is current
67+
run: |
68+
if ! git diff --quiet -- apps/sanity/extract.json; then
69+
echo "::error::apps/sanity/extract.json is stale. Run 'pnpm typegen' and commit the result."
70+
git diff --stat -- apps/sanity/extract.json
71+
exit 1
72+
fi
73+
74+
preview:
75+
needs: verify
76+
if: github.event_name == 'pull_request' && github.base_ref == 'dev'
77+
runs-on: ubuntu-latest
78+
permissions:
79+
contents: read
80+
pull-requests: write
81+
steps:
82+
- uses: actions/checkout@v4
83+
84+
- uses: pnpm/action-setup@v4
85+
86+
- uses: actions/setup-node@v4
87+
with:
88+
node-version-file: ".nvmrc"
89+
cache: "pnpm"
90+
91+
- name: Install dependencies
92+
run: pnpm install --frozen-lockfile
93+
94+
- name: Generate Sanity Types
95+
run: pnpm typegen
96+
env:
97+
SANITY_STUDIO_PROJECT_ID: hfh83o0w
98+
SANITY_STUDIO_DATASET: dev
99+
100+
- name: Generate Cloudflare Types
101+
run: pnpm --filter @codingcatdev/site cf-typegen
102+
103+
- name: Build site (preview)
104+
run: pnpm --filter @codingcatdev/site build
105+
106+
- name: Upload Cloudflare Worker Preview Version
107+
id: upload_preview
108+
run: |
109+
OUTPUT=$(pnpm --filter @codingcatdev/site exec wrangler versions upload --tag "pr-${PR_NUMBER}" --message "PR #${PR_NUMBER}: ${PR_TITLE}")
110+
echo "$OUTPUT"
111+
112+
PREVIEW_URL=$(echo "$OUTPUT" | grep -i "Version Preview URL:" | awk '{print $NF}' | head -n 1)
113+
VERSION_ID=$(echo "$OUTPUT" | grep -i "Worker Version ID:" | awk '{print $NF}' | head -n 1)
114+
115+
echo "preview_url=$PREVIEW_URL" >> $GITHUB_OUTPUT
116+
echo "version_id=$VERSION_ID" >> $GITHUB_OUTPUT
117+
118+
echo "::notice title=Cloudflare Worker Preview URL::${PREVIEW_URL}"
119+
120+
echo "### ⚡ Cloudflare Worker Preview Ready" >> $GITHUB_STEP_SUMMARY
121+
echo "" >> $GITHUB_STEP_SUMMARY
122+
echo "- **Preview URL**: [${PREVIEW_URL}](${PREVIEW_URL})" >> $GITHUB_STEP_SUMMARY
123+
echo "- **Version ID**: \`${VERSION_ID}\`" >> $GITHUB_STEP_SUMMARY
124+
echo "- **Target Worker**: \`codingcatdev-dev\`" >> $GITHUB_STEP_SUMMARY
125+
126+
if [ -n "$PREVIEW_URL" ]; then
127+
{
128+
echo "### ⚡ Cloudflare Worker Preview Ready!"
129+
echo ""
130+
echo "| Environment | URL |"
131+
echo "|---|---|"
132+
echo "| **PR Preview** | [${PREVIEW_URL}](${PREVIEW_URL}) |"
133+
echo "| **Dev Custom Domain** | [https://dev.codingcat.dev](https://dev.codingcat.dev) |"
134+
echo ""
135+
echo "- **Worker Version ID**: \`${VERSION_ID}\`"
136+
echo "- **Protection**: Restricted to \`@codingcat.dev\` accounts via Cloudflare Zero Trust Access"
137+
} > pr_comment.md
138+
139+
COMMENT_ID=$(gh api "repos/${{ github.repository }}/issues/${PR_NUMBER}/comments" --jq '.[] | select((.user.login=="github-actions[bot]" or .user.login=="app/github-actions") and (.body | contains("Cloudflare Worker Preview Ready"))) | .id' | tail -n 1)
140+
141+
if [ -n "$COMMENT_ID" ]; then
142+
gh api -X PATCH "repos/${{ github.repository }}/issues/comments/${COMMENT_ID}" -f body="$(cat pr_comment.md)"
143+
else
144+
gh pr comment "$PR_NUMBER" --body-file pr_comment.md
145+
fi
146+
fi
147+
env:
148+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
149+
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
150+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
151+
PR_NUMBER: ${{ github.event.pull_request.number }}
152+
PR_TITLE: ${{ github.event.pull_request.title }}
153+
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Deploy Site to Cloudflare Workers
2+
3+
on:
4+
push:
5+
branches: [dev, main]
6+
paths:
7+
- "apps/site/**"
8+
- "packages/**"
9+
- "pnpm-lock.yaml"
10+
- ".github/workflows/deploy-workers.yml"
11+
12+
concurrency:
13+
group: deploy-site-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
deploy-dev:
18+
if: github.ref == 'refs/heads/dev'
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- uses: pnpm/action-setup@v4
24+
25+
- uses: actions/setup-node@v4
26+
with:
27+
node-version-file: ".nvmrc"
28+
cache: "pnpm"
29+
30+
- name: Install dependencies
31+
run: pnpm install --frozen-lockfile
32+
33+
- name: Generate Sanity Types
34+
run: pnpm typegen
35+
env:
36+
SANITY_STUDIO_PROJECT_ID: hfh83o0w
37+
SANITY_STUDIO_DATASET: dev
38+
39+
- name: Generate Cloudflare Types
40+
run: pnpm --filter @codingcatdev/site cf-typegen
41+
42+
- name: Build site (dev)
43+
run: pnpm --filter @codingcatdev/site build
44+
45+
- name: Deploy to Cloudflare Workers (dev.codingcat.dev)
46+
run: pnpm --filter @codingcatdev/site exec wrangler deploy
47+
env:
48+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
49+
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
50+
51+
deploy-production:
52+
if: github.ref == 'refs/heads/main'
53+
runs-on: ubuntu-latest
54+
steps:
55+
- uses: actions/checkout@v4
56+
57+
- uses: pnpm/action-setup@v4
58+
59+
- uses: actions/setup-node@v4
60+
with:
61+
node-version-file: ".nvmrc"
62+
cache: "pnpm"
63+
64+
- name: Install dependencies
65+
run: pnpm install --frozen-lockfile
66+
67+
- name: Generate Sanity Types
68+
run: pnpm typegen
69+
env:
70+
SANITY_STUDIO_PROJECT_ID: hfh83o0w
71+
SANITY_STUDIO_DATASET: production
72+
73+
- name: Generate Cloudflare Types
74+
run: pnpm --filter @codingcatdev/site cf-typegen
75+
76+
- name: Build site (production)
77+
run: pnpm --filter @codingcatdev/site build:production
78+
79+
- name: Deploy to Cloudflare Workers (codingcat.dev)
80+
run: pnpm --filter @codingcatdev/site exec wrangler deploy --env production
81+
env:
82+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
83+
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}

‎.github/workflows/deploy.yml‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
name: Deploy Sanity Studio
22

33
on:
4+
workflow_dispatch:
45
push:
56
branches: [dev, main]
7+
paths:
8+
- "apps/sanity/**"
9+
- "pnpm-lock.yaml"
10+
- ".github/workflows/deploy.yml"
611

712
jobs:
813
deploy-dev:
9-
if: github.ref == 'refs/heads/dev'
14+
if: github.ref == 'refs/heads/dev' || github.event_name == 'workflow_dispatch'
1015
runs-on: ubuntu-latest
1116
environment: dev
1217

@@ -17,7 +22,7 @@ jobs:
1722

1823
- uses: actions/setup-node@v4
1924
with:
20-
node-version: "22"
25+
node-version-file: ".nvmrc"
2126
cache: "pnpm"
2227

2328
- name: Install dependencies
@@ -29,6 +34,8 @@ jobs:
2934
env:
3035
SANITY_AUTH_TOKEN: ${{ secrets.SANITY_AUTH_TOKEN }}
3136
SANITY_STUDIO_HOSTNAME: ${{ vars.SANITY_STUDIO_HOSTNAME }}
37+
SANITY_STUDIO_DATASET: ${{ vars.SANITY_STUDIO_DATASET }}
38+
SANITY_STUDIO_PROJECT_ID: ${{ vars.SANITY_STUDIO_PROJECT_ID }}
3239

3340
deploy-production:
3441
if: github.ref == 'refs/heads/main'
@@ -42,7 +49,7 @@ jobs:
4249

4350
- uses: actions/setup-node@v4
4451
with:
45-
node-version: "22"
52+
node-version-file: ".nvmrc"
4653
cache: "pnpm"
4754

4855
- name: Install dependencies
@@ -54,3 +61,5 @@ jobs:
5461
env:
5562
SANITY_AUTH_TOKEN: ${{ secrets.SANITY_AUTH_TOKEN }}
5663
SANITY_STUDIO_HOSTNAME: ${{ vars.SANITY_STUDIO_HOSTNAME }}
64+
SANITY_STUDIO_DATASET: ${{ vars.SANITY_STUDIO_DATASET }}
65+
SANITY_STUDIO_PROJECT_ID: ${{ vars.SANITY_STUDIO_PROJECT_ID }}

‎.gitignore‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,6 @@ yarn-error.log*
3838
!.vscode/mcp.json
3939
# pnpm workspace — root pnpm-lock.yaml is the lockfile
4040
package-lock.json
41+
42+
# agents teamwork
43+
.agents/

‎.nvmrc‎

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

‎CLAUDE.md‎

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# codingcat.dev
2+
3+
pnpm monorepo. Node >= 22.12 (see `.nvmrc`); pnpm 10.34.1.
4+
5+
## Packages
6+
7+
| Path | Package | What it is |
8+
|---|---|---|
9+
| `apps/site` | `@codingcatdev/site` | **Astro 7 SSR on Cloudflare Workers** — the public site. Active development. |
10+
| `apps/web` | `@codingcatdev/web` | Next.js 16 app. Being retired: its public half is replaced by `apps/site`; the dashboard + sponsor portal move to `admin.codingcat.dev`. |
11+
| `apps/sanity` | `@codingcatdev/sanity` | Sanity Studio v6, deployed to Sanity hosting. |
12+
13+
Root scripts target `apps/site`. Use `pnpm dev:dashboard` / `build:dashboard` for the Next app, `pnpm dev:studio` for the Studio.
14+
15+
## In-flight migration
16+
17+
Moving from Next.js on Vercel to Astro 7 SSR on Cloudflare Workers, with Sanity
18+
upgraded to v6 and the video/AI pipeline (Remotion, Gemini, ElevenLabs,
19+
NotebookLM, GCS, YouTube upload) dropped. Auth moves from Supabase to
20+
better-auth on Cloudflare D1.
21+
22+
Branch note: `dev` still holds the **pre-Next Astro app** and `main` holds the
23+
Next app — `main` is ahead. Harvest old Astro code with `git show dev:<path>`,
24+
never by checking `dev` out over the working tree.
25+
26+
## Conventions that bite
27+
28+
- **`output: "server"` — there is no `getStaticPaths` anywhere.** Pagination is a
29+
runtime bounds check on `Astro.params`, not a build-time param list.
30+
- **GROQ queries must live in `.ts` files.** Sanity TypeGen cannot parse `.astro`
31+
frontmatter, so `defineQuery` calls in `.astro` files are silently skipped.
32+
- **Never read secrets from `import.meta.env`.** Vite inlines non-`PUBLIC_` vars
33+
into the server bundle, baking them into the deployed Worker script. Read them
34+
from `import { env } from "cloudflare:workers"` — `@astrojs/cloudflare` v14
35+
reduced `Runtime` to `{ cfContext }` and deprecated `locals.runtime`.
36+
- **Cloudflare bindings are not inherited into `env.production`.** Anything added
37+
to the top level of `wrangler.jsonc` must be repeated there.
38+
- **The environment is chosen at BUILD time, via `CLOUDFLARE_ENV`.** The adapter
39+
flattens `wrangler.jsonc` into `dist/server/wrangler.json` and writes
40+
`.wrangler/deploy/config.json`, which redirects wrangler away from the source
41+
config — so `wrangler deploy --env production` on a default build silently
42+
ships the *dev* dataset under the *dev* worker name. Use
43+
`pnpm --filter @codingcatdev/site build:production`.
44+
- **`Astro.site` is baked in at build time**, so it cannot carry a per-env
45+
origin. Canonicals, `og:url`, feeds and the sitemap read `Astro.locals.siteUrl`,
46+
resolved per request from the `SITE_URL` var in middleware.
47+
- **`stegaClean` anything bound to an attribute**, `<meta>`, JSON-LD, or XML.
48+
Stega's zero-width characters are harmless in text nodes and corrupting in
49+
`href`, `src`, and feeds.
50+
- **`@sanity/icons` v5 has no root-entry icon exports.** Import from subpaths:
51+
`import {UserIcon} from "@sanity/icons/User"`.
52+
- **`astro-portabletext` uses singular `type` / `block` / `mark` keys**, and mark
53+
components read the mark definition from `node.markDef`, not `node`. Both fail
54+
silently — the component simply never runs.
55+
- **A self-closing `<script />` in an `.astro` file breaks props inference**, so
56+
`Astro.props` degrades to `Record<string, any>`. Use paired tags.
57+
- `apps/sanity/plugins/podcast-rss/` is vendored, not an npm dep — see its README.
58+
59+
## Agent skills
60+
61+
Sanity guidance is vendored in `.agents/skills/` (pinned by `skills-lock.json`).
62+
The Astro-relevant ones for this migration:
63+
64+
- `.agents/skills/portable-text-serialization/rules/astro.md` — `astro-portabletext`
65+
usage. Note it uses **singular** `type` / `block` / `mark` keys, unlike
66+
`@portabletext/react`'s plural `types` / `marks`.
67+
- `.agents/skills/sanity-best-practices/references/astro.md`
68+
- `.agents/skills/content-modeling-best-practices/`, `seo-aeo-best-practices/`
69+
70+
`.agents/skills/sanity-live-cache-components/` documents the Next.js
71+
`cacheComponents` + `next-sanity` pattern being removed. It applies only to
72+
`apps/web` and should be deleted with it.
73+
74+
Cloudflare guidance comes from the Claude Code cloudflare plugin — invoke the
75+
`cloudflare`, `workers-best-practices`, and `wrangler` skills rather than
76+
guessing Workers APIs.
77+
78+
## Verifying
79+
80+
`pnpm lint`, `pnpm typecheck`, `pnpm build` cover `apps/site`; CI also builds the
81+
Studio and fails if `apps/sanity/extract.json` has drifted from the schema.
82+
83+
Bindings only resolve under `wrangler dev`, not `astro dev` — verify anything
84+
touching `locals.runtime.env`, D1, or OG image generation against a real Worker.
85+
86+
`apps/site/baseline/` holds pre-migration production `sitemap.xml` and RSS
87+
snapshots (472 URLs, 50 items per feed). Diff against them before cutover; a
88+
changed podcast GUID re-publishes every episode to Apple/Spotify.

‎apps/sanity/components/CodeSandboxPreview.tsx‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React from "react";
2-
import { RenderPreviewCallbackProps } from "sanity";
32
// TODO: Add stronger typing
43

54
const CodePenPreview = (props: any) => {

0 commit comments

Comments
 (0)