Visitar URL original
Comparing dev...feat/astro-cloudflare · CodingCatDev/codingcat.dev · GitHub
Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: CodingCatDev/codingcat.dev
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: dev
Choose a base ref
...
head repository: CodingCatDev/codingcat.dev
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: feat/astro-cloudflare
Choose a head ref
Checking mergeability… Don’t worry, you can still create the pull request.
  • 14 commits
  • 192 files changed
  • 2 contributors

Commits on Aug 18, 2026

  1. 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
    codercatdev and claude committed Aug 18, 2026
    Configuration menu
    Copy the full SHA
    7196305 View commit details
    Browse the repository at this point in the history
  2. 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
    codercatdev and claude committed Aug 18, 2026
    Configuration menu
    Copy the full SHA
    4a95ece View commit details
    Browse the repository at this point in the history
  3. 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
    codercatdev and claude committed Aug 18, 2026
    Configuration menu
    Copy the full SHA
    1b01b48 View commit details
    Browse the repository at this point in the history
  4. 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
    codercatdev and claude committed Aug 18, 2026
    Configuration menu
    Copy the full SHA
    ed452ba View commit details
    Browse the repository at this point in the history
  5. 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
    codercatdev and claude committed Aug 18, 2026
    Configuration menu
    Copy the full SHA
    90b26d7 View commit details
    Browse the repository at this point in the history
  6. 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
    codercatdev and claude committed Aug 18, 2026
    Configuration menu
    Copy the full SHA
    4d5cdf4 View commit details
    Browse the repository at this point in the history
  7. 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
    codercatdev and claude committed Aug 18, 2026
    Configuration menu
    Copy the full SHA
    c5cc7a3 View commit details
    Browse the repository at this point in the history
  8. 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
    codercatdev and claude committed Aug 18, 2026
    Configuration menu
    Copy the full SHA
    36da187 View commit details
    Browse the repository at this point in the history

Commits on Oct 7, 2026

  1. Configuration menu
    Copy the full SHA
    ae87e5c View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    bed81e7 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    c82bd03 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    ce71b9c View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    011d01f View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    ab8cc23 View commit details
    Browse the repository at this point in the history
Loading