Skip to content

refactor: rename content to posts, and give each post one folder - #37

Merged
37ng merged 2 commits into
mainfrom
claude/bitcoin-assets-reorganize-9d034d
Sep 8, 2026
Merged

37ng merged 2 commits into
mainfrom
claude/bitcoin-assets-reorganize-9d034d

Conversation

@37ng

@37ng 37ng commented Sep 8, 2026

Copy link
Copy Markdown
Owner

What changed

A post's files were spread over three trees. Now one folder holds all of it.

src/content/ → src/posts/, and everything a post owns moved inside its own folder:

src/posts/bitcoin/
  index.mdx
  assets/    bg.webp, coin.glb        (was src/assets/bitcoin/)
  data/      bars.json, epochs.json, …
  diagrams/  BitcoinTimeline.tsx, …
  lib/       bitcoin-timeline.ts, flag-rate.ts, flagged-blocks.ts,
             offchain-revenue.ts, pool-flag-rate.ts, pool-flag-sample.ts,
             sha256.ts + their tests

src/assets/ is gone. src/lib/ keeps only what the whole site uses: posts.ts and stage.ts.

Two smaller moves in the same pass:

  • src/components/ui/{Button,Panel,Tag}.tsx moved up into src/components/. Nothing imported them, so this was a rename plus one doc line.
  • src/lib/fan.ts was inlined into PostsFan.tsx, which now exports CURATED_ORDER, sortCurated and cardNo. index.astro and HeroStage.astro import them from there.

Why

Nothing in the old layout said which src/lib/ file belonged to which post — flag-rate.ts and stage.ts sat side by side, one owned by the bitcoin post and one owned by the site. The folder now answers that, and the import style follows from it: a post's own files are relative (../lib/bitcoin-timeline, ../data/bars.json, ../assets/coin.glb?url), and @/ means site-wide.

Things a reviewer should know

generate-art.mjs needed real logic, not a path swap. It mirrored art-src/ into src/assets/, but the slug folder now sits before assets/, so the mapping is art-src/<slug>/x.png → src/posts/<slug>/assets/x.webp. A master with no slug folder is now an error rather than a file written where no post reads it.

The test glob was silently under-matching. tsx --test src/**/*.test.ts was unquoted, so sh expanded ** to one level and matched src/lib/ only. The tests now sit four levels deep, so this would have started passing vacuously. Quoting it hands the glob to node, which walks the tree. Same 39 tests before and after.

stage.ts deliberately stayed in src/lib/. Moving it into HeroStage.astro was tried and does not work: an .astro module exports only its component, so PostsFan.tsx cannot import getStage/setStage from it ([MISSING_EXPORT] at build). It also has three consumers across the hydration line, and HeroStage's import graph includes the 1 MB BitcoinCoin3D chunk that PostsFan currently does not pull in.

The fan/caption numbering was the one behavioural risk in inlining fan.ts, since the static caption and the hydrated panel number posts off the same array positions. Checked in the browser: prologue 000, bitcoin 001, and the caption's 001 · 2026-07-28 matches the bitcoin card.

Verification

npm run verify clean — Prettier, astro check 0 errors, build emits all 3 pages with the fingerprinted coin.glb and bg.webp, 39/39 tests. Dev server renders the homepage art, the coin and all five bitcoin figures with no new console errors.

🤖 Generated with Claude Code

37ng and others added 2 commits September 8, 2026 09:57
A post's files were spread over three trees: prose and data in
src/content/<slug>/, stage art and 3D models in src/assets/<slug>/, and the
logic its figures read in src/lib/ mixed in with the site-wide modules.
Nothing said which lib file belonged to which post.

Now one folder holds all of it:

  src/posts/bitcoin/
    index.mdx
    assets/    bg.webp, coin.glb        (was src/assets/bitcoin/)
    data/      bars.json, epochs.json, ...
    diagrams/  BitcoinTimeline.tsx, ...
    lib/       bitcoin-timeline.ts, flag-rate.ts, flagged-blocks.ts,
               offchain-revenue.ts, pool-flag-rate.ts, pool-flag-sample.ts,
               sha256.ts and their tests

src/lib/ keeps only what the whole site uses: fan.ts, posts.ts, stage.ts.
src/assets/ is gone.

The import rule follows from the layout: a post's own files are relative
(../lib/bitcoin-timeline, ../data/bars.json, ../assets/coin.glb?url), and @/
is only for site-wide modules. HeroStage.astro still reaches into the post
folder for the coin and the timeline, now as @/posts/bitcoin/diagrams/.

Two things outside the move had to follow it:

generate-art.mjs mirrored art-src/ into src/assets/, but the slug folder now
sits before assets/, so a plain prefix swap would not do. It maps
art-src/<slug>/x.png to src/posts/<slug>/assets/x.webp, and a master with no
slug folder is an error rather than a file written somewhere no post reads.

The test glob src/**/*.test.ts was unquoted, so sh expanded it to one level
and matched src/lib/ only. The tests now sit four levels deep. Quoting it
hands the glob to node, which walks the tree.

Verified: 39/39 tests pass, astro check reports 0 errors, the build emits all
three pages with the fingerprinted coin.glb and bg.webp, and the dev server
renders the homepage art, the coin and all five figures.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@37ng
37ng merged commit 84c76e5 into main Sep 8, 2026
1 check passed
@37ng
37ng deleted the claude/bitcoin-assets-reorganize-9d034d branch September 8, 2026 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant