All posts

8 min readPost 36

After 90 blog images: why our diagrams shrank to ant-sized text, and how we built a zero-CDN lightbox

By 34 bilingual posts and 90 WebP images, every automated blog check was green—yet opening the latest posts on a desktop screen revealed 1600px multi-column diagrams shrunk into unreadable ant tracks with no way to zoom. On 29 November we rebuilt our diagrams at 760–800px logical width @2x with prose-grade typography, replaced drawings with real sanitized captures, and added a 229-line zero-CDN Vue lightbox that cleans up across SPA language switches.

On this page
  1. Doing the pixel math: why a 1600 px wide diagram always turns blurry inline
  2. Real sanitized captures beat drawn mockups
  3. A 229-line zero-CDN native Vue lightbox built for dual static builds

By late November, Obituary's development blog had grown to 34 bilingual posts and 90 WebP images. On every build, site/blog/.vitepress/posts.test.mjs verified the whole set: every file under 300 KB, at most 1600 px wide, exact width and height matching the WebP header, lazy loading, and full alt text and captions. Every automated check was green.

Then we opened the four newest posts on a real 1440×900 laptop screen and tried to read them start to finish. The problem jumped right off the page:

You couldn't read the labels inside our architecture diagrams—and clicking an image did nothing.

Labels that looked sharp at 12 px in a full-size preview shrank into blurry ant tracks once dropped into the article column. Reading a function name meant right-clicking "Open image in new tab" and zooming manually. On 29 November we stopped to fix the whole visual pipeline (fc63039): redoing our diagram canvas and typography rules, swapping drawn approximations for real sanitized captures, and shipping a zero-CDN native lightbox across both static builds.

Before-and-after clarity comparison and lightbox architecture: top contrasts 1600x820 wide diagrams shrinking to 5.5-6px text inside the 46rem column and 36rem banner cap versus 760-800px logical @2x stacked diagrams with 15-16px type and real captures; bottom shows the 229-line zero-CDN ImageLightbox.vue design
The pixel math behind rebuilding our diagrams at 800px @2x (top), and our 229-line zero-CDN native Vue lightbox (bottom).

Doing the pixel math: why a 1600 px wide diagram always turns blurry inline ​

Three numbers in the stylesheet explained the whole failure:

  • The article prose column is --column: 46rem (736 px at a 16 px root font). Even with horizontal figure bleed (--bleed), an inline diagram peaks around 880 px.
  • A post's first figure also becomes its top banner (PostPage.vue). To keep tall screenshots from pushing the headline off-screen, bannerSize capped banner height at 36rem (576 px), while the dotted .stage mat consumed up to 3rem (48 px on each side) of padding.
  • Meanwhile, our four architecture diagrams from 25–28 November had been laid out as wide 1600×820 to 1600×880 multi-column canvases with 11–13 px labels.

Drop a 1600 px canvas into a 736 px reading column and the browser shrinks it to ~45%. Those crisp 12 px labels collapse to 5.5–6 px on screen—barely legible in English and smeared solid in Chinese. Exporting higher resolution does not solve that; as long as the diagram's logical width is double the reading column, the type will always render half-size.

Fixing readability at the source: 760–800 px logical @2x, ≥15–16 px type, and a taller banner cap ​

Instead of drawing giant landscape canvases and hoping readers zoom in, we rewrote our diagram spec around the actual reading column:

  • Design at column width, export at @2x: Every diagram now uses a 760–800 px logical canvas rendered at 2× device scale (1600 px physical WebP). Inside the 736–800 px column it displays near 1:1 logical scale—crisp on HiDPI screens and never squashed on standard displays.
  • Stack vertically and match prose type: Multi-column side-by-side cramming gave way to clean stacked vertical sections with 15–16 px body labels (right alongside the blog's 1.0625rem / 17 px prose) and no wide decorative frames.
  • Unpinch PostPage.vue: We raised bannerSize's height cap from 36rem to 68rem (keeping aspectRatio pre-sized for zero layout shift) and tightened .stage padding from clamp(0.75rem, 4.5vw, 3rem) down to clamp(0.5rem, 1.4vw, 1rem) so the diagram gets the pixels instead of the dotted border.

All eight Chinese and English diagrams across the 25–28 November posts were rebuilt to this spec, naturally growing taller so every box breathes:

DiagramBefore (W × H)After (zh)After (en)
doctor-and-list1600 × 8601600 × 16721600 × 1674
quota-plan-a1600 × 8201600 × 16981600 × 1912
tray-win32-sequence1600 × 8201600 × 15701600 × 1696
admission-and-osroot1600 × 8801600 × 19761600 × 2118

Real sanitized captures beat drawn mockups ​

Diagrams earn their place for architecture and state machines, but when the real UI already runs, drawing a fake mockup wastes time and hides real details. In the same pass we added four real sanitized captures in both languages (bringing the blog from 90 images to 94):

  • Live obit doctor HTML diagnostic report (doctor-report.zh/en.webp): Generated by actually running obit doctor inside an isolated demo directory (C:\Users\Public\obit-demo\doctor-shot), expanding a failing area to show the copyable yellow fix commands and the 1-day auto-burial footer—never touching personal paths.
  • Live obit-gui calendar multiselect (calendar-multiselect.zh/en.webp): Captured directly from the desktop window using sample data with Tomorrow's column header selected and the floating squircle batch capsule active at the bottom.

Every new image also gets a full-size visual check before commit. posts.test.mjs catches oversized files, wrong dimensions, and path leaks, but only a human eye catches awkward line breaks or cramped labels.

A 229-line zero-CDN native Vue lightbox built for dual static builds ​

Even when diagrams read comfortably inline, readers still click dense captures and timelines expecting them to expand.

We deliberately skipped external lightbox CDNs and third-party gallery packages. Obituary's site builds twice on every release—GitHub Pages (dist/) and the mainland China mirror (dist-cn/), where the mirror enforces zero external network requests. Bringing in a third-party viewer also tends to fight VitePress's SPA router on cleanup.

site/blog/.vitepress/theme/ImageLightbox.vue solves the whole job in 229 lines of plain Vue 3, zero new npm packages, mounted once inside Layout.vue. The real engineering lives in four edge cases:

  1. Selective event delegation: A single document click listener checks .post .banner .stage img, .post .post-body figure img, .post .vp-doc img, ignoring non-left clicks, modifier keys (Ctrl/Cmd/Shift/Alt), images inside <a> or <button>, .svg icons, tiny assets under 120×120, and explicit .no-lightbox / data-no-lightbox opt-outs.
  2. Zero ghost modals or stuck scroll locks across SPA navigation: Switching Chinese ↔ English in VitePress or hitting browser Back swaps routes without a page reload. If a lightbox stays mounted or leaves document.documentElement.style.overflow = 'hidden' behind, the next page freezes. Watching () => route.path to call close(), backed by unlockScroll() inside onBeforeUnmount, guarantees clean teardown on every route exit.
  3. Accessible dialog semantics and focus return: The backdrop exposes role="dialog" and aria-modal="true" with localized labels from copy.ts (lightboxDialog and lightboxClose). Opening moves focus to the close button on nextTick; closing via Esc, backdrop click, or the button restores focus to triggerEl (when isConnected) using { preventScroll: true } so the reader never loses their scroll position.
  4. Restrained cues and reduced-motion support: PostPage.vue and prose.css add cursor: zoom-in and a subtle scale(1.006) hover hint. Inside the dialog, the image scales cleanly within max-width: 92vw; max-height: 82vh above its original <figcaption>, and @media (prefers-reduced-motion: reduce) disables transitions automatically.
Live 1440x900 desktop capture of the blog's native ImageLightbox.vue open over the real calendar multiselect screenshot, displaying the enlarged image, matching caption bar, and circular close button on a blurred dark backdrop
The native lightbox running live at 1440×900: clicking any post figure expands the image locally with zero external requests, shows its original caption below, and dismisses cleanly with Esc or a backdrop click.

Reading through the updated posts afterwards felt completely different: every architecture diagram is legible straight in the column, and a single click opens any real capture full-screen. Automated tests catch broken images and missing metadata, but actually reading the rendered site like a visitor is still the only way to catch text that technically exists yet nobody can read.

All posts