Something went wrong. Try again.
My website. cameron.stream
Something went wrong. Try again.
TypeScript
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157import assert from "node:assert/strict";import test from "node:test";import { parseBlogDocument } from "./data.ts";
test("parses a Leaflet-owned Blog record without a repository content file", () => { const uri = "at://did:plc:gfrmhdmjvxn2sjedzboeudef/site.standard.document/example"; const post = parseBlogDocument(uri, { $type: "site.standard.document", site: "at://did:plc:gfrmhdmjvxn2sjedzboeudef/site.standard.publication/3md7ylshxzk2y", title: "Example", path: "/example", publishedAt: "2026-07-21T00:00:00.000Z", tags: ["blog"], content: { $type: "pub.leaflet.content", pages: [{ $type: "pub.leaflet.pages.linearDocument", id: "2df5434c-af1e-43cf-b08f-5562f46a07f0", blocks: [ { block: { $type: "pub.leaflet.blocks.header", level: 1, plaintext: "Example" } }, { block: { $type: "pub.leaflet.blocks.text", plaintext: "Leaflet remains the source." } }, ], }], }, });
assert.equal(post.uri, uri); assert.equal(post.rkey, "example"); assert.equal(post.slug, "example"); assert.equal(post.title, "Example"); assert.equal(post.body, "Leaflet remains the source."); assert.deepEqual(post.tags, ["blog"]);});
test("renders rich Leaflet blocks through the read-only adapter", () => { const post = parseBlogDocument( "at://did:plc:gfrmhdmjvxn2sjedzboeudef/site.standard.document/rich", { title: "Rich", path: "/rich", publishedAt: "2026-07-21T00:00:00.000Z", tags: ["blog"], content: { $type: "pub.leaflet.content", pages: [{ $type: "pub.leaflet.pages.linearDocument", id: "39149734-aa55-45a7-8ed9-46257527b5dc", blocks: [ { block: { $type: "pub.leaflet.blocks.unorderedList", children: [ { content: { plaintext: "one" } }, { content: { plaintext: "two" } }, ] } }, { block: { $type: "pub.leaflet.blocks.horizontalRule" } }, { block: { $type: "pub.leaflet.blocks.website", src: "https://example.com", title: "Example", description: "A card", } }, ], }], }, }, );
assert.match(post.body, /- one\n- two/); assert.match(post.body, /---/); assert.match(post.body, /<leaflet-card\b/);});
test("coalesces adjacent rich-text facets without exposing Markdown delimiters", () => { const sentence = "The Letta Agent SDK will feel familiar to people who have used the Claude Agent SDK. "; const post = parseBlogDocument( "at://did:plc:gfrmhdmjvxn2sjedzboeudef/site.standard.document/adjacent-facets", { title: "Adjacent facets", path: "/adjacent-facets", publishedAt: "2026-08-18T19:59:27.602Z", content: { $type: "pub.leaflet.content", pages: [{ $type: "pub.leaflet.pages.linearDocument", id: "7e289be1-eacb-463e-bace-159fca42a1c6", blocks: [{ block: { $type: "pub.leaflet.blocks.text", plaintext: sentence, facets: [ { index: { byteStart: 0, byteEnd: 15 }, features: [{ $type: "pub.leaflet.richtext.facet#bold" }], }, { index: { byteStart: 15, byteEnd: 16 }, features: [ { $type: "pub.leaflet.richtext.facet#bold" }, { $type: "pub.leaflet.richtext.facet#italic" }, ], }, { index: { byteStart: 16, byteEnd: 84 }, features: [{ $type: "pub.leaflet.richtext.facet#bold" }], }, ], } }], }], }, }, );
assert.equal(post.body, `**${sentence.slice(0, 84)}**`); assert.doesNotMatch(post.body, /\*{3} \*{3}/);});
test("drops dangling legacy footnote references without disturbing defined notes", () => { const post = parseBlogDocument( "at://did:plc:gfrmhdmjvxn2sjedzboeudef/site.standard.document/footnotes", { title: "Footnotes", path: "/footnotes", publishedAt: "2026-08-15T00:00:00.000Z", tags: ["blog"], content: { $type: "pub.leaflet.content", pages: [{ $type: "pub.leaflet.pages.linearDocument", id: "d918939a-047c-4d41-a328-35572f3f82e5", blocks: [ { block: { $type: "pub.leaflet.blocks.text", plaintext: "The missing note disappears[^missing].", } }, { block: { $type: "pub.leaflet.blocks.text", plaintext: "The defined note remains[^kept].", } }, { block: { $type: "pub.leaflet.blocks.text", plaintext: "[^kept]: The note body.", } }, { block: { $type: "pub.leaflet.blocks.code", language: "javascript", plaintext: "const pattern = /[^missing]/;", } }, ], }], }, }, );
assert.match(post.body, /The missing note disappears\./); assert.equal((post.body.match(/\[\^missing\]/g) ?? []).length, 1); assert.match(post.body, /The defined note remains\[\^kept\]\./); assert.match(post.body, /\[\^kept\]: The note body\./); assert.match(post.body, /const pattern = \/\[\^missing\]\//);});