mirror of
https://github.com/bitbaum/botsmann.git
synced 2026-12-03 22:57:03 +01:00
lib/blog.ts and lib/knowledge.ts read their folders with readCollection / readEntry instead of their own readdir + parseFrontmatter loops; the published: true opt-in stays. lib/longform uses bip-kit's normalizeMarkdown, which started as a copy of ours. Same posts and guides, same fields; items with the same date now sort by title instead of by filesystem order. The blog content doc still described the separate MDX content repo. Co-authored-by: Cursor <cursoragent@cursor.com>
37 lines
1.5 KiB
TypeScript
37 lines
1.5 KiB
TypeScript
/**
|
|
* The ONE long-form markdown pipeline. Both surfaces — the blog
|
|
* (content/blog/*.md) and the Knowledge Center (content/knowledge/**\/*.md) —
|
|
* parse through bip-kit's typed-block parser and render through its reference
|
|
* renderer (lib/longform/LongformBody).
|
|
*
|
|
* Typed blocks are the security model: markdown becomes a discriminated
|
|
* union and the renderer emits React elements from typed data, so there is no
|
|
* HTML/JSX passthrough for content to hide in. That is what let the MDX stack
|
|
* (next-mdx-remote + remark/rehype + a hand-rolled component map per surface)
|
|
* go away — an MDX file could evaluate arbitrary JSX; a markdown file cannot.
|
|
*
|
|
* bip-kit's `normalizeMarkdown` is the lenient step in front of the strict
|
|
* parser: `* ` bullets, nested items (74 such lines live in the guides), a
|
|
* body `# h1`, single-quoted figure captions. Code fences are left alone.
|
|
*/
|
|
|
|
import { extractToc, normalizeMarkdown, parseContentBlocks, readingTime } from 'bip-kit';
|
|
import type { ContentBlock, TocEntry } from 'bip-kit';
|
|
|
|
export interface ParsedLongform {
|
|
blocks: ContentBlock[];
|
|
toc: TocEntry[];
|
|
/** Word-count based minutes (200 wpm, min 1). */
|
|
readingMinutes: number;
|
|
}
|
|
|
|
/** Parse a long-form markdown body into bip-kit typed blocks + TOC. */
|
|
export function parseLongform(markdown: string): ParsedLongform {
|
|
const blocks = parseContentBlocks(normalizeMarkdown(markdown));
|
|
return {
|
|
blocks,
|
|
toc: extractToc(blocks),
|
|
readingMinutes: readingTime(blocks).minutes,
|
|
};
|
|
}
|