Source
Pagez's code, with index.ts as the library's entry, vite.ts as the Vite plugin, and cli.ts as the command. elements/ reads and renders the elements a page uses, and theme.css is the theme a page with no CSS gets.
Folders
- elements/
The element layer: one
@name.htmlfile, read into its parts, rendered at build time and run in the browser (elements.md). Nothing here imports the rest of Pagez. Its tests are intests/elements/.
Code
- args.ts
pagez build|check|dev|preview [folder] [--port <n>], orpagez rules [id], read into what to run, or into what to print and the code to exit with. A mistake is one line and the usage, never a stack.--portis fordevandpreview, and serves on that port or fails, so a script gets the port it asked for. - browser.ts
The elements a page uses that send something to the browser: CSS from a top-level
<style>, or behavior from a top-level<script>. The page's finished HTML is scanned for their tags, so an element in the frame or written by another element counts, and an element the page doesn't use ships nothing. A page with no behavior loads no JavaScript. - built.d.ts
Tells TypeScript that an import ending in
?builtis a file's text, ready to ship. Thebuiltplugin in vite.config.ts does the loading. - check.ts
pagez checkcompiles every pagebuildwould, without Vite's bundle ordist/, and lists what to fix. Each page that fails prints its failure, one a line, with its id, and each warning prints too. So one run lists every page's mistake, where a build stops at its first. - cli.ts
pagez buildbuilds the pages in a folder, each.mdat its folder's path, to the folder'sdist/.pagez devserves them while they're written, andpagez previewserves what was built. - definitions.ts
A page's elements are defined in one of two places (pages). One is an
@x-tag.htmlanywhere in the site, kept with the pages that use it. The other is a definition in the page, one=htmlblock holding<template element="x-tag">and its<style>and<script>. - expressions.ts
Prose refers to values, and elements compute (pages). So a
${…}in a page is a path intopage, the page's metadata, such as${page.title}, and nothing else: no call, no operator and no other name. Anything more fails, at the expression. - head.ts
A page's head is its frame's, with what follows from its metadata added. The frame is the nearest
frame.html, beside the page or in a folder above it, or with none, Pagez's minimal document, so both go through the same code. - index.ts
pagez — Markdown, as pages.
compileturns a page into its parts, andwriteputs them together as the HTML thatpagez(), from@amitkaps/pagez/vite, hands to Vite. A mistake in a page is aFileError, which names its file. - page.ts
One Markz page in, its parts out. They're the page in its frame with its head written, Pagez's CSS and its elements', the stylesheets it links, and its one module.
- parts.ts
Each part of an element that runs is a module of its own (
elements/file.ts). They're the template, which the build runs in a Vite server, andsetup, which the page's script imports and Vite bundles. - redirects.ts
A page that moved lists the paths it used to have under
redirects, and Pagez writes each todist/_redirectsas a 301 to where the page is now (site.tschecks them). Cloudflare Pages and Netlify read that file, before the files they serve. - references.ts
A page links the files beside it as they're written (Files and links). So Pagez checks that each one is there, and the build fails on one that isn't rather than the page showing a broken image.
- report.ts
What
buildprints when it's done. Each page's row has its HTML, gzipped, as it's sent, the time it took to compile, and the elements that give it behavior. So a page that grows heavy or slow shows where the cost is. - rules.ts
pagez rules <id>prints one rule from the docs the package ships, so an agent reads the rule for the version it runs. An error or a warning prints when it fails or warns, and then its rule. A Markz code prints Markz's text for it. With no id, every rule prints, one a line. - site.ts
The pages in a folder, and what each one is made from (pages). The folder Pagez builds is the root, and every
.mdunder it is a page, at its folder's path. - text.ts
The page as Markz writes it, with three of its nodes Pagez's (Markz and Pagez): each
${…}printed frompage, each element with a definition rendered from it, and each definition's block left out. Everything else is Markz's own HTML, raw=htmlblocks included. - theme.css
Pagez's theme, for a page with no CSS of its own. It makes what Markdown writes readable, in the system's fonts, light or dark. A style.css replaces it, and any other CSS beats it, since it's all in one layer.
- vite.ts
pagez()builds the site in Vite's root through Vite, every page, each a.mdat its folder's path (site.ts).