Introducing a new way to review your PRs.

Read the announcement

calicastle / cali.so

Personal website for Cali Castle

View on GitHub

21 documents · Updated Sep 21, 2026

docs / published-content-delivery

Published content delivery

Published content delivery is the public site's content system for turning authored posts, archived newsletters, project records, and approved photos into localized pages. It keeps content data separate from route views, while shared MDX components and public asset routes give each page a consistent reading and media experience. This page is a child of Public site experience; locale choice and search-facing routes are covered in Localization, navigation, and discovery.

Content sources

The public site combines file-based writing with small typed registries and a published media snapshot. Each source has a clear public role:

Content sourcePublic rolePublic languages or variants
Blog MDXPosts, post indexes, dates, covers, reading data, and related-post linksChinese and English files
Newsletter MDXRead-only newsletter archive pagesChinese and English files
Project registryProject list with names, descriptions, icons, and destinationsChinese and English fields
Published Photo SelectionOrdered photo wall and homepage photo previewShared media data with bilingual alt text and labels
Supporting registries and snapshotsHome-page experience, books, records, and external-link previewsMostly shared records with localized labels where needed

Blog posts

Blog posts are published only when their slug is in the explicit public post list. The loader reads a Chinese MDX file and its English partner, validates the front matter, and returns one post model that includes both editions plus display data such as its cover and reading length. lib/content.ts and lib/public-content-routes.ts define this content boundary.

The blog index orders posts by publication date and groups them by year. A post page uses the selected locale's title, description, and body, then adds article metadata, a table of contents, related posts, and a reading header around the body. This lets one route view serve both language families without mixing their text.

References: lib/content.ts• L13-23 lib/content.ts• L147-184 lib/content.ts• L245-267 lib/public-content-routes.ts• L1-21 app/…/blog-index-page.tsx• L11-71 app/…/blog-post-page.tsx• L32-51

Archived newsletters

Newsletters are exposed as a fixed read-only archive rather than as an active subscription system. The archive allowlist controls which numeric IDs can resolve, and the loader pairs each Chinese MDX file with its English file before the page selects the matching edition. lib/newsletters.ts owns the archive data and its known image dimensions.

The archive page states that sending and subscription features are retired. It renders the selected body with the same shared MDX components used by posts, while applying newsletter-specific image checks so only known archive images are shown.

References: lib/public-content-routes.ts• L16-28 lib/newsletters.ts• L15-75 app/…/newsletter-archive-page.tsx• L16-36 app/…/newsletter-archive-page.tsx• L39-93

Projects and supporting registries

Projects are curated public records rather than authored documents. lib/projects.ts gives each record a Chinese and English name, a description, an icon, and a destination. The project view turns local destinations into locale-aware site links and marks outside destinations as external links.

The home page uses related registries for supporting content. lib/personal.ts supplies experience, books, and records, while lib/public-page-metadata.ts supplies page titles and descriptions. These records support the site's public story without creating separate content routes.

References: lib/projects.ts• L1-85 lib/personal.ts• L4-19 lib/personal.ts• L51-87 lib/public-page-metadata.ts• L1-56 app/…/projects-page.tsx• L13-89 app/…/home-page.tsx• L45-57 app/…/home-page.tsx• L104-193

Published photo selection

Photos use a different source from writing: the public page reads the current Published Photo Selection from the media system. A Published Photo Selection is an ordered snapshot of approved assets, public Renditions, bilingual Alt Text, and optional display details. This keeps owner edits private until publication and gives the public page a stable content set.

The photo route and the home page read the same selection. The photo route shows every item in a masonry wall, while the home page uses only the first three items for its preview card. If there is no published selection, the public page shows an empty state; local development may use fixtures without changing production behavior.

References: lib/…/repository.ts• L197-235 lib/…/server.ts• L71-112 app/…/photos-page.tsx• L11-29 app/…/home-page.tsx• L85-102 app/…/home-page.tsx• L199-207

Public route families

Public content routes use one view per content type and two explicit locale families. The route files provide the locale and route parameters, while shared views load the content and render the page.

Route selection

The public route boundary checks blog slugs and newsletter IDs before a request reaches a content page. Unknown values are rewritten to the public not-found page, so a file that exists locally is not automatically public.

The route families map to these public experiences:

Route familyContent resultLocale form
/blog and /blog/:slugBlog index and article pagesChinese root paths and /en/... paths
/newsletters/:idRead-only newsletter archiveChinese root paths and /en/... paths
/projectsCurated project listChinese root path and /en/projects
/photosPublished photo wallChinese root path and /en/photos

References: proxy.ts• L10-24 proxy.ts• L74-82 app/…/page.tsx• L5-14 app/…/page.tsx• L5-14 app/…/page.tsx• L12-33 app/…/page.tsx• L12-33

Page composition

Route pages stay small because they pass locale and parameters to shared views. Blog routes also expose static post parameters and derive article metadata from the same post model used for rendering. Newsletter routes validate archive IDs before loading either metadata or page content.

The shared public document supplies the surrounding site shell. It adds the footer, dock, theme, ambient layer, analytics, and route transition wrapper around the content view. Content delivery therefore controls the page's data and body, while the public site experience controls the shared frame.

This diagram shows how a public request becomes a localized content page.

flowchart LR
    R[Public URL] --> G[Locale route]
    G --> V[Shared content view]
    V --> S[Content source]
    S --> L[Selected language or publication]
    L --> M[Metadata and page body]
    M --> F[Shared public site shell]

References: app/…/page.tsx• L7-18 app/…/page.tsx• L7-18 app/…/page.tsx• L5-14 app/…/page.tsx• L5-17 app/…/site-document.tsx• L78-114

MDX rendering

MDX is the authoring format for blog posts and newsletters. The page views choose the body for the active locale, then pass it through shared Markdown and MDX rules so links, images, code, diagrams, and interactive content behave as site content rather than as raw HTML.

Article body pipeline

Blog bodies are rendered on the server with GitHub-flavored Markdown, Mermaid support, heading IDs, and code styling. English heading IDs receive a language prefix so the Chinese and English editions do not compete for the same anchors. The body is cached for a long lifetime after its source and locale are chosen.

Newsletter bodies use the same shared components and Markdown support, but do not add the blog-only article rail and code plug-ins. Their archive wrapper keeps the content read-only and applies its own image policy.

References: app/…/blog-post-page.tsx• L110-150 app/…/blog-post-page.tsx• L161-249 app/…/newsletter-archive-page.tsx• L54-93

MDX components

The MDX component map turns authored elements into site-aware content. Local links gain the active locale, external links can show a favicon and a stored preview, and post images resolve from a post's content directory. Named components add code blocks, Mermaid diagrams, photo stacks, tweets, time charts, and inline product names.

Authors can use image dimensions encoded in the post image source, while the renderer supplies the public content path and the zoom behavior. Mermaid diagrams render with the site's light and dark color variables, and photo-stack wrappers keep grouped images and captions semantic.

References: components/…/mdx-components.tsx• L15-75 components/…/photo-stack.tsx• L1-13 components/…/mermaid-diagram.tsx• L11-61 lib/link-previews.ts• L12-35

Asset delivery

Content assets follow the source that owns them. Blog and newsletter images stay beside their MDX and use a narrow public content route, while published photos use public Rendition URLs from the media store.

Colocated content images

The content image route serves only image paths under blog or newsletter directories. It accepts a restricted file name shape, reads from the matching content directory, returns the correct image type, and gives the result a long immutable cache lifetime. A path outside that shape or a missing file returns not found.

Blog MDX image references are converted to /content/blog/<slug>/<file>. Newsletter images use the known archive image map and fail fast when an image is not part of that map. These checks keep authored media inside the public content boundary.

References: app/…/route.ts• L4-36 components/…/mdx-components.tsx• L15-31 app/…/newsletter-archive-page.tsx• L16-36 lib/newsletters.ts• L22-32

Photo Renditions

Public photos never expose the protected Original. The public selection carries approved Renditions with their dimensions and delivery URLs, and the photo wall chooses an appropriate Rendition for the displayed or expanded image. This separates public delivery quality from private source storage.

The photo wall uses bilingual Alt Text on each image. Optional location and camera details appear only in the expanded view, so the wall stays visually quiet while the lightbox still provides the approved context.

References: lib/…/repository.ts• L197-224 lib/…/repository.ts• L562-680 components/published-photo-wall.tsx• L53-83 components/published-photo-wall.tsx• L86-145 components/zoom-image.tsx• L41-103

Publication boundary

Public content is a deliberate release boundary rather than a direct view of every source record. Blog and newsletter allowlists decide which authored records are routable, while the Published Photo Selection decides which approved media records are visible.

Snapshot visibility

Photo publication creates an immutable selection snapshot and makes it the active public selection. The public reader loads that active snapshot and verifies that its entries and required Renditions are complete before rendering. Publishing also invalidates the public selection cache so a new release can reach the public pages.

This gives the owner a private draft stage and gives visitors a coherent set of photos. Archive or purge actions can withdraw an asset from the published selection without making unrelated draft edits public.

References: lib/…/service.ts• L154-187 lib/…/repository.ts• L351-515 lib/…/repository.ts• L568-625 lib/…/CONTEXT.md• L49-79

Loading states

The blog article and photo wall show shaped loading shells while content reads complete. The shells preserve the main layout and give assistive technology a loading status, while a missing photo publication resolves to a clear empty message instead of a broken wall.

References: app/…/blog-post-page.tsx• L54-107 app/…/photos-page.tsx• L20-29 components/published-photo-wall.tsx• L126-163

Change checklist

When these files or sections are changed, remember to consider these:

  • When adding or renaming a blog slug, update the published slug allowlist and confirm that the Chinese file, English file, route checks, indexes, feeds, and sitemap still use the same slug contract.
  • When adding or renaming an archived newsletter, update the archive ID allowlist and the known image map together. Check both locale routes because each route validates the same ID.
  • When changing MDX image syntax or colocated asset paths, keep the authoring format, the MDX component map, and the restricted content image route aligned.
  • When changing the Published Photo Selection shape, update its snapshot reader, cache invalidation, home-page preview, full photo wall, and bilingual accessibility fields as one contract.
  • When changing a project's local URL or a public registry field, check locale path conversion and the home or project view that consumes it.

Important failure modes

TriggerConsequenceGuard
A blog slug is absent from publishedPostSlugsIts article cannot resolve through the public route, even if its MDX files existKeep the allowlist and post files in sync
A newsletter ID is absent from archivedNewsletterIdsBoth locale archive routes return not foundAdd the ID and its known images as one change
A post image does not use the required file-and-dimensions formMDX rendering fails instead of producing an image with unknown sizeUse the ./file#widthxheight form
A published photo snapshot lacks an item or required RenditionThe public photo read rejects the incomplete snapshotPublish only eligible ready assets and preserve snapshot rows
Public selection cache invalidation fails after publicationThe new selection is stored but public readers may keep the old cached viewTreat the publish result as an operational error and retry invalidation
A local or external project URL is classified incorrectlyA local link can lose locale routing or an external link can lose its safe external behaviorKeep URL classification consistent with ProjectsPageView

Key files

FileWhy to read it
lib/content.tsDefines the blog post model, bilingual loading, ordering, reading data, and related-post behavior.
lib/public-content-routes.tsDefines the explicit public boundary for posts and archived newsletters.
lib/newsletters.tsDefines the read-only newsletter archive model and image allowlist.
app/…/blog-post-page.tsxShows the article lifecycle from route parameters through metadata, MDX, and related posts.
app/…/newsletter-archive-page.tsxShows how a bilingual newsletter becomes a read-only MDX page.
components/…/mdx-components.tsxDefines the shared contract between authored MDX and public site behavior.
app/…/route.tsDefines the public boundary for colocated blog and newsletter images.
lib/…/repository.tsDefines the public photo snapshot and its safe Rendition data.
lib/…/server.tsDefines cached public photo reads and development-only fallback behavior.
components/published-photo-wall.tsxShows how published photo data becomes the public wall and expanded details.
lib/projects.tsDefines the curated project records used by the projects page.
app/…/site-document.tsxShows how content views sit inside the shared public document and site shell.