Skip to content

posts in gleam - #172

Merged
alii merged 1 commit into
masterfrom
gleam-posts
Sep 3, 2026
Merged

alii merged 1 commit into
masterfrom
gleam-posts

Conversation

@alii

@alii alii commented Sep 2, 2026

Copy link
Copy Markdown
Owner

Eight of the nine posts are Gleam. A post is now a record, blog/post.Post, with name, slug, date (built with date.utc(2022, 1, 6)), hidden, excerpt, keywords and body: fn() -> Element, and blog/posts.all() lists them in the old order. Each post is its own module under src/blog/, e.g. blog/esm.gleam.

How they were converted. Not by hand: a small script (in tmp/, gitignored) has the TypeScript compiler transpile each post's JSX to React.createElement calls, which applies JSX's whitespace, entity and {' '} rules exactly, then walks that tree and prints Gleam. stripIndent code samples are evaluated at conversion time into plain string literals. Anything it could not map it refused, which is how the inventory below was checked. Every converted post page is byte-identical to the pre-rewrite prerendered HTML.

Components that moved with them. Note (site/note, with react-icons behind one-line atoms in site/icons), the code block and shell (site/code: code.block(source, code.TypeScript, [code.Filename("x.ts")]), code.shell(...); shiki's codeToHtml is the one atom, sharing the same highlighter instance as the TSX one), and ExternalLink (site/external_link, pure Gleam). html gained the tags the posts use, attribute gained flag and style. note.tsx and its shim are deleted; posts_ffi.ts is deleted, site/posts is plain Gleam over the records.

The TS that still reads posts (api/posts, api/og, the RSS route) goes through blog/posts.ts, which is now a two-line view over the Gleam list, typed by Gleam's declarations. api/posts shapes its JSON explicitly since the record holds a Gleam list and a function.

A rule learned. Shims are copied into build/, so a relative import of an image or TSX from a shim resolves into that copy, where assets do not exist. Shims import project files through @/.

Left for the next PR. The railways post: its diagrams use framer-motion, and it uses Terminal, SafariConsole, MacWindow. It is registered as a Gleam post whose body and metadata come from the TSX through a shim, so the list and the pages do not care.

All 12 prerendered pages identical, /api/posts, /feed.xml and /api/og checked over HTTP, no server-only code in browser chunks, typecheck and lint clean.

@vercel

vercel Bot commented Sep 2, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
website Ready Ready Preview Sep 2, 2026 9:19pm UTC

@alii
alii merged commit 3cd357b into master Sep 3, 2026
3 checks passed

This branch was successfully deployed

1 active deployment
Preview — 3f05b0cb Deployed Sep 2, 2026 by vercel[bot]
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