kawapress #
The core of KawaPress: the site config, the plugin APIs, data loaders and the types they share. Import it in kawapress.config.ts, in plugins and in data loader files.
Site config #
defineConfig— Declares the site config inkawapress.config.ts. It only adds types.definePreset— Creates a preset: a function that merges the preset's config with the config a site passes to it.HeadAttrs— Attributes of a<head>tag.HeadConfig— One<head>tag written as JSON data: the tag name, its attributes, and optional raw inner content.HeadTag— Names of the tags a site may add to<head>.KawapressConfig— The site config thatkawapress.config.tsexports.KawapressPreset— A function that returns a site config with the preset's defaults merged in; made bydefinePreset.LocaleConfig— One language of a multilingual site.LocaleDirection— Writing direction of a language.LocaleLink— A language the visitor can switch to, with the link to its version of the current page.PageRewrites— Moves pages to other routes: rules from a source path pattern to a page path, or a function from the source path to the page path. Paths are relative to srcDir and keep their.mdextension.ResolvedSiteConfig— The site config with every default applied and every value checked, after all pluginconfig()hooks ran. Generator plugins read it inconfigResolved()instead of repeating KawaPress's defaults.ResolvedSiteData— Site data resolved for the current route and locale.SiteConfig— The site config asconfig()handlers of plugins see it: raw values, before defaults are applied.SiteData— Raw site data exposed to the client via virtual module.ThemeConfig— Theme configuration of a site. The interface is empty on purpose: a theme or a plugin adds the fields it understands from its own package, and every package that is imported contributes to the same type.
Plugins #
addPageComponent— Declares that the page being rendered usescomponent.BuildArtifactsContext— What abuildArtifacts()handler receives: every built page, a way to write extra files into the output folder, and a way to import a module the build wrote.definePlugin— Declares a Generator Plugin that runs while the site is built and served. It only adds types.defineRuntimePlugin— Declares a Runtime Plugin, which runs in the browser and while pages are rendered on the server. It only adds types.GeneratorPluginAPI— Whatsetup(api)of a Generator Plugin receives: one method per hook. A method adds a handler; the handlers of several plugins run in plugin order.GeneratorPluginHandler— A hook handler. It receives the hook's value and may be asynchronous.GeneratorPluginSetup— Thesetup()of a Generator Plugin. It registers hooks onapi.KawaPressPlugin— A Generator Plugin: a stablenameand asetup()that registers hooks.MaybePromise— A value, or a promise of it.OUTLET_NAMES— Every outlet a theme can render. The list is the public contract between plugins (which contribute interface pieces) and themes (which draw the default content of each outlet).OutletItem— A collected outlet item.idandownerare filled in by KawaPress.OutletItemInput— What a plugin passes toapi.prependToOutlet()orapi.appendToOutlet().OutletName— Name of an outlet; one ofOUTLET_NAMES.OutletRegistry— Outlet items grouped by outlet name. Each side is in plugin install order.PageBuildArtifact— A built page aspageArtifact()andbuildArtifacts()handlers see it.PageComponent— One component that the template of a page uses.PageComponentEnv— Part of the Markdownenvthat carries the page components.PageDataContext— Where the page being processed comes from. Generator-only; never sent to the browser.PageDataHandler— ApageData()handler. It receives the page data to change and where the page comes from.PageOrigin— Where a page comes from: a Markdown file in srcDir, or a plugin'spages().PluginPageContent— What a plugin gives for one page: its Markdown and extra frontmatter.PluginPagesContext— What a generator function ofpages()receives.PluginPagesGenerator— Returns the pages of a route with parameters, one item per page that gives every parameter. A route without parameters is a single page: a Markdown string or aPluginPageContent.PluginPagesSource— The second argument ofpages(): a file template or a generator function.RouteParams— Parameters a route template declares, read from the literal the route is written as:'/team/[id]'gives{ id: string }. A route without parameters, or a route that is not a literal, has none.RuntimePlugin— A Runtime Plugin: a stablenameand asetup()that registers hooks.RuntimePluginAPI— Whatsetup(api)of a Runtime Plugin receives: methods to place components in outlets and to reach the Vue app and the router.RuntimePluginHandler— A Runtime Plugin hook handler. It receives the hook's value and may be asynchronous.RuntimePluginSetup— Thesetup()of a Runtime Plugin. It registers hooks onapi.
Data loading #
ContentData— One page a content loader returns.ContentExcerpt— How a content loader produces excerpts:truefor the default, a separator string, or a function that fillsexcerptof the parsed file.ContentExcerptFile— A parsed Markdown file given to a customexcerptfunction.ContentLoader— The loadercreateContentLoaderreturns. It is a loader withwatch, and itsload()can also be called without arguments.ContentLoaderOptions— Options ofcreateContentLoader.createContentLoader— Creates a data loader that lists the Markdown pages matching a pattern, with their URL and frontmatter.DataLoader— A data loader in either form: tracked, or VitePress-compatible withwatch.DataLoaderConfig— Facts about the site that a loader can use: its root, source and public folders, and the site data.DataLoaderContext— Whatload()can use to read local files; whatever it reads is tracked.DataLoaderGlobOptions— Options for matching files, passed to tinyglobby; the working folder and path form are fixed.DataLoaderOptions— Extra options of a data loader.defineLoader— Declares a data loader that reads local files; export it from a.data.tsfile and import it from pages and layouts.TrackedDataLoader— Recommended form: nowatch,load()receives the context.WatchDataLoader— VitePress-compatible form:load()receives the fileswatchmatches, then the context.
Markdown #
createMarkdownRenderer— Creates a standalone Markdown renderer for build-time tools such as demo source loaders. It has the same asynchronous rendering shape as the site compiler, without creating a page or running site plugins.MarkdownItPluginHost— The parts of a markdown-it compatible instance that a plugin installer needs.MarkdownRendererOptions— Options ofcreateMarkdownRenderer.normalizeFrontmatterSource— Rewrites a source whose frontmatter is a JSON object into the frontmatter form the Markdown pipeline reads. Any other source is returned unchanged.useMarkdownItPlugin— Installs a markdown-it plugin on a Markdown renderer and keeps the types of the plugin's parameters.
Pages #
markdownPagePathToRoutePath— Converts a source-relative Markdown page path to its public route path.PageData— The data of a page that reaches the browser: its route, title, headings and frontmatter.PageFrontmatter— Frontmatter of a page. KawaPress keeps the data open, so any key an author writes is allowed and typedunknown. A plugin that reads a key declares it from its own package, which gives every reader the exact type:PageHeader— A heading of a page, with the headings nested below it.PageMetadata— Title, description and title template of a page.resolveDocumentTitle— Works out the text of<title>for a page: itstitleTemplateapplied to the page title, orPage title | Site title.resolveHeadingTitle— The plain-text title of a heading: the text its author wrote on the heading line, without the Markdown formatting markup and without HTML tags.resolvePageMetadata— Readstitle,descriptionandtitleTemplatefrom frontmatter. Without atitle, the first level-1 heading is the title.SitePage— One page of the site, whether it is a Markdown file or a plugin's page.
Routing #
resolveLocaleIndex— Finds the locale key a route path belongs to.rootowns every path outside the other locale prefixes; the longest matching prefix wins.Route— The route the app currently shows. A documentation site only needs a lookup from a path to a page, so the route is plain data: no matcher, no params, no nested records.RouteGuard— Runs before a navigation commits. Returningfalsecancels it; returning nothing (ortrue) lets it through. There is no redirect: a guard that wants another URL callsrouter.push()itself.RouteHook— Runs after a navigation committed.Router— Navigation API of a KawaPress site, a small subset of Vue Router's.withBase— Prefixes a site path with the sitebase. External URLs and#anchors are returned as they are.withoutBase— Takes the sitebaseoff a path, or returnsundefinedwhen the path is not under it.
Dead links #
DeadLink— An internal link that points at nothing.DeadLinkConfig— How the build treats dead internal links.DeadLinkIgnore— A link is skipped when the value matches itshrefortarget.DeadLinkReason— Why KawaPress treats an internal link as dead.DeadLinkSite— What the dead link check needs to know about the site: its routes, the heading anchors of each page and the public files.findDeadLinks— Checks the links of every page against the routes, heading anchors and public files of the site, and returns the dead ones sorted by source and line.findPageDeadLinks— Checks the links of one page the wayfindDeadLinksdoes.formatDeadLink— Formats a dead link as one report line,source:line href reason, the way build and dev print it.LinkRecord— One internal link written in a Markdown page.PageLinks— Links and heading IDs of one page, as seen by the dead link checker.ResolvedDeadLinkConfig— The dead link config with its defaults applied.
Theming #
KAWA_DEFAULT_TOKENS— Neutral defaults emitted into every page.light-dark()follows the visitor's color scheme;color-scheme: light darkmust live in the same layer for the function to resolve without a theme.KAWA_LAYER_ORDER— Style layers, lowest priority first. Site CSS written without a layer wins over all three, so site authors override themes with plain CSS.KAWA_TOKEN_NAMES— Style tokens every KawaPress site has, no matter which theme is installed. Plugins only read these names; themes override the values.KawaTokenName— Name of a--kawa-*CSS variable that plugins can use.
Utilities #
assertJsonSerializable— Throws when a value cannot be written as JSON, naming the path of the first value that cannot.JsonOperationOptions— Names used in the error message of the JSON helpers.parseJson— Parses JSON text and nameslabelin the error when the text is invalid.stringifyJson— Checks that a value can be written as JSON and returns its JSON text.
Frontmatter #
FrontmatterConfig— How the site checks page frontmatter.FrontmatterIssue— A frontmatter value that breaks a rule.FrontmatterSchema— Rules for the frontmatter of every page: a Zod object, or a schema from another Standard Schema library such as Valibot or ArkType.FrontmatterTypo— An unknown top-level key that looks like a typo of a known one.StandardSchemaIssue— One problemvalidate()of a Standard Schema found.StandardSchemaProps— The~standardproperty of a Standard Schema.StandardSchemaResult— Whatvalidate()of a Standard Schema returns.StandardSchemaV1— A schema from a library that follows Standard Schema (https://standardschema.dev), such as Zod, Valibot or ArkType. KawaPress only needs the~standardproperty, so a site can use any of them.


Comments