Repository navigation
posts in gleam - #172
Merged
Merged
posts in gleam#172
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Eight of the nine posts are Gleam. A post is now a record,
blog/post.Post, withname,slug,date(built withdate.utc(2022, 1, 6)),hidden,excerpt,keywordsandbody: fn() -> Element, andblog/posts.all()lists them in the old order. Each post is its own module undersrc/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 toReact.createElementcalls, which applies JSX's whitespace, entity and{' '}rules exactly, then walks that tree and prints Gleam.stripIndentcode 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 insite/icons), the code block and shell (site/code:code.block(source, code.TypeScript, [code.Filename("x.ts")]),code.shell(...); shiki'scodeToHtmlis the one atom, sharing the same highlighter instance as the TSX one), andExternalLink(site/external_link, pure Gleam).htmlgained the tags the posts use,attributegainedflagandstyle.note.tsxand its shim are deleted;posts_ffi.tsis deleted,site/postsis plain Gleam over the records.The TS that still reads posts (
api/posts,api/og, the RSS route) goes throughblog/posts.ts, which is now a two-line view over the Gleam list, typed by Gleam's declarations.api/postsshapes 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.xmland/api/ogchecked over HTTP, no server-only code in browser chunks, typecheck and lint clean.