Skip to content

feat: ambient mm illustrations (48 = 12 slots × 4 心境) + themed-plate pipeline#11

Merged
PanQiWei merged 3 commits into
PanQiWei:mainfrom
pandazki:main
Apr 23, 2026
Merged

feat: ambient mm illustrations (48 = 12 slots × 4 心境) + themed-plate pipeline#11
PanQiWei merged 3 commits into
PanQiWei:mainfrom
pandazki:main

Conversation

@pandazki

Copy link
Copy Markdown
Contributor

Cherry-picked from fork pandazki/advanced-agentic-dev-patterns — originally PR #1 there, already merged to the fork's main. Opening to upstream now.

Summary

  • 48 ambient illustrations across 12 mental-model sections — 12 slots × 4 心境 variants (ZH day 水墨 / ZH night 夜绢 / EN day 18c natural-philosophy plate / EN night Victorian candlelit etching). Each variant drawn natively rather than as a photo-negative of another; all share the vermilion chapter seal (正 / 控 / 熵 / 系 / 形 / 因 / 符) and the site's warm tokens as the only legal palette.
  • Themed-plate sync pipeline: sync-content.mjs now detects a <stem>.dark.png sibling next to an inline image and emits a <span class="themed-plate"> with paired <img> tags so CSS can swap per [data-theme]. Old mkdocs data-card wrappers are retired from the article body (info-cards will come back as a separate artefact, alongside the wiki module redo).
  • Shiki dual-theme wiring fix: Astro emits --shiki-dark CSS vars but keys them on prefers-color-scheme; this site uses [data-theme="dark"] on <html>, so dark-mode code blocks were rendering near-black text on near-black paper-sunk bg. Override added.
  • Mermaid retheme: theme:"base" driven by tokens.css (paper / ink / rule / vermilion / gold / celadon). Strips author-supplied style X fill:#… overrides, re-inits on [data-theme] flip, adds CJK fallback to the font stack for bilingual diagrams.
  • Bilingual scroll memory: Topbar.astro now saves {sectionId, ratio} into sessionStorage on language switch and restores it via astro:page-load (Hall uses <ClientRouter /> so the inline script only fires once otherwise). Ratios, not pixels, keep the landing point meaningful across the ~30-50% length gap between ZH and EN.

Slot map

Ch Slot Seal
01 Orthogonality the-forces
02 Cybernetics helmsman, second-order
03 Entropy what-is-entropy, maxwells-demon
04 Operating System from-demon-to-os
05 Fractal sumeru-in-a-mustard-seed, the-generator, worlds-within-worlds
06 Causality humes-fork, the-ladder
07 Symbols × Connectionism two-roads

Only sections where a single ambient image earns its place got a slot; heavy-taxonomy sections (OCP maps, OS break-points, symbols-connectionism analytics) stay text-only on purpose.

Test plan

  • cd site && npm run test:sync → 8/8 pass (transformCards no longer emits card image; themed-plate emitted when .dark.png sibling exists)
  • npm run sync produces 24 themed-plate spans across src/content/mm/{zh,en}/**/0*.mdgrep -rl themed-plate site/src/content/mm | wc -l shows 24
  • Visit each chapter, toggle day/night, toggle ZH/EN — the plate's <img> swaps correctly, page stays on approximately the same paragraph
  • /zh/mm/entropy → scroll to §02 因果结构 — mermaid renders in warm site palette (not pink/yellow), arrow labels render with CJK font
  • /en/mm/entropy → scroll to §02 Causal structure — the ASCII positive feedback loop code block is readable in dark mode (was near-black on near-black before)
  • No extraneous #hash left on the URL after language switch

🤖 Generated with Claude Code

pandazki and others added 3 commits April 23, 2026 21:29
…/code theming

Unifies the plumbing that lets mental-model chapters carry ambient
illustrations with native day/night variants, and smooths two friction
points in the bilingual reading experience.

- sync-content.mjs: retire the mkdocs-era card emission from the article
  body (the `<div class="mm-article" data-card=…>` wrapper now unwraps to
  prose-only); when a `<stem>.dark.png` sibling exists alongside an inline
  `![](assets/X.png)`, emit a `<span class="themed-plate">` carrying both
  `.themed-plate__light` and `.themed-plate__dark` `<img>` tags so the CSS
  layer can swap them per `[data-theme]`. Tests updated accordingly.

- reader-site.css: add the themed-plate visibility rules; gate Shiki's
  `--shiki-dark` CSS variables on `[data-theme="dark"]` so dual-theme
  code blocks actually switch (Astro's default wiring uses
  `prefers-color-scheme`, which doesn't match the site's manual toggle —
  the symptom was near-black code text on near-black paper-sunk in dark).

- Topbar.astro: preserve approximate reading position across zh ↔ en
  switches. On chapter pages we capture {sectionId, offsetRatio} into
  sessionStorage keyed by destination pathname, then restore on
  `astro:page-load` (required because Hall uses `<ClientRouter />` — an
  SPA swap, so the inline script only runs once on the initial load).
  Ratios, not pixels, keep the landing point meaningful across the
  ~30-50% length gap between ZH and EN. Non-chapter pages fall back to
  a whole-page scrollY ratio. URL stays hash-free.

- mermaid-loader.ts: replace the default `dark`/`neutral` mermaid palettes
  with `theme: "base"` driven by tokens.css (paper / ink / rule /
  vermilion / gold / celadon). Strip author-supplied inline `style X
  fill:#…` lines before rendering so they can't re-assert pink/yellow
  defaults. Watch `[data-theme]` via MutationObserver and re-init +
  re-render existing diagrams on flip. Font stack now includes LXGW
  WenKai / Noto Serif SC fallbacks so the Chinese edge labels in a
  bilingual flowchart don't drop to a random system font.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Replaces the mkdocs-era infograph card PNGs on 12 mental-model sections
with hand-brushed ambient illustrations, generated via gpt-image-2 on
fal.ai. Each slot ships four "心境" variants — ZH day (宣纸水墨), ZH night
(夜绢研墨), EN day (18c natural-philosophy plate), EN night (Victorian
candlelit etching) — each variant drawn natively, not as a palette flip
of another. The four share a common vermilion seal carrying one Chinese
character per chapter (正 / 控 / 熵 / 系 / 形 / 因 / 符) as the across-
culture anchor, and the site's warm tokens (paper / ink / vermilion /
gold / celadon) as the only legal palette — no cool blues, no tech-
infographic tropes.

Slots and anchor paragraphs follow the judgment-pass from
`.claude/notes/mental-models-illustration-slots.md`: only sections where
a single image genuinely carries weight (the car spinning its tires,
the helmsman on open water, Boltzmann's desk, Maxwell's demon at the
door, demon → institution, seed ↔ mountain, Koch snowflake, Indra's
pearl, Hume's billiard, Pearl's ladder, two roads). Heavy-taxonomy
sections (OCP maps, OS break-points, symbol-connectionism analytics)
stay text-only on purpose.

Integration uses the themed-plate pipeline from the previous commit:
each slot now has `assets/X.png` + `assets/X.dark.png` next to each
other in both `docs/zh/...` and `docs/en/...`, plus a single plain
`![alt](assets/X.png)` reference at the anchor paragraph in the source
markdown. sync-content.mjs emits the paired <img>s; reader-site.css
swaps them on `[data-theme]`.

- 12 slots × 4 variants = 48 new/updated PNGs (24 light files replace
  the old card PNGs; 24 `.dark.png` are new).
- 12 source markdown pairs (ZH + EN) gain one inline `![alt](…)` line
  each at the slot's anchor paragraph.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
feat: ambient mm illustrations (48 = 12 slots × 4 心境) + themed-plate pipeline
@PanQiWei
PanQiWei self-requested a review April 23, 2026 13:37
@PanQiWei

Copy link
Copy Markdown
Owner

Thanks! LGTM

@PanQiWei
PanQiWei merged commit 4f81a7b into PanQiWei:main Apr 23, 2026
5 checks passed
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.

2 participants