@pagina/core
v0.3.0
Published
Article model for pagina: parses an article folder of YAML and Markdown into a typed manifest plus HTML fragments, and builds the section-level search index.
Maintainers
Readme
@pagina/core
The article model behind pagina. It reads an article folder
— an article.yaml, some Markdown, whatever those pages reference — and returns a typed manifest
plus rendered HTML fragments. It writes nothing, serves nothing, and knows nothing about a shell.
npm install @pagina/coreimport { renderArticle } from "@pagina/core";
// `fs` is a small `ContentFs` port — read, exists, list — so the same renderer runs over a
// directory, a zip, or a database without knowing which it is.
const article = await renderArticle({ fs, base: "/" });
// article.pages[n].html, article.nav, article.diagnosticsDiagnostics are the contract, not a log: a nav entry without a file, a dead link, a missing
snippet, a broken anchor, or a cover that does not exist all arrive as structured Diagnostic
records naming the page, and strict (the default) turns them into a thrown PaginaBuildError.
That separation is the point: @pagina/core produces the manifest,
@pagina/shell-static is one shell over it, and a Laravel Blade view or a
React app can consume the same manifest without pulling in a static-site generator.
What is in here
- Front matter and config —
parseArticleConfig,parseFrontMatter, thearticle.yamlschema, and the Kineglyph theme plumbing (kineglyphColorVars,kineglyphThemeHref). - Markdown —
createMarkdown/renderMarkdown, admonitions, snippet expansion (--8<---style includes that reach outside the folder), and{...}attribute syntax. - Figures —
extractFigurespulls Kineglyph scene scripts out of a page so a build step can pre-render them, andinlineFigureSvgsputs the results back. - Links and references —
rewriteLinksturns folder-relative Markdown links into site URLs; the strict mode behind pagina's "a dead link fails the build" rule lives here. - Search —
@pagina/core/searchbuilds the section-level index that a site writes to onesearch.json. - SEO and reading time —
seo.ts,readingMinutes.
Subpath exports
| Specifier | What it is |
| --- | --- |
| @pagina/core | the article model |
| @pagina/core/search | the search index builder, importable on its own so a host that only wants search does not pay for Markdown |
Licence
MIT — see LICENSE.
