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 in kawapress.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 that kawapress.config.ts exports.
  • KawapressPreset — A function that returns a site config with the preset's defaults merged in; made by definePreset.
  • 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 .md extension.
  • ResolvedSiteConfig — The site config with every default applied and every value checked, after all plugin config() hooks ran. Generator plugins read it in configResolved() instead of repeating KawaPress's defaults.
  • ResolvedSiteData — Site data resolved for the current route and locale.
  • SiteConfig — The site config as config() 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 uses component.
  • BuildArtifactsContext — What a buildArtifacts() 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 — What setup(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 — The setup() of a Generator Plugin. It registers hooks on api.
  • KawaPressPlugin — A Generator Plugin: a stable name and a setup() 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. id and owner are filled in by KawaPress.
  • OutletItemInput — What a plugin passes to api.prependToOutlet() or api.appendToOutlet().
  • OutletName — Name of an outlet; one of OUTLET_NAMES.
  • OutletRegistry — Outlet items grouped by outlet name. Each side is in plugin install order.
  • PageBuildArtifact — A built page as pageArtifact() and buildArtifacts() handlers see it.
  • PageComponent — One component that the template of a page uses.
  • PageComponentEnv — Part of the Markdown env that carries the page components.
  • PageDataContext — Where the page being processed comes from. Generator-only; never sent to the browser.
  • PageDataHandler — A pageData() 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's pages().
  • PluginPageContent — What a plugin gives for one page: its Markdown and extra frontmatter.
  • PluginPagesContext — What a generator function of pages() 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 a PluginPageContent.
  • PluginPagesSource — The second argument of pages(): 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 stable name and a setup() that registers hooks.
  • RuntimePluginAPI — What setup(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 — The setup() of a Runtime Plugin. It registers hooks on api.

Data loading #

  • ContentData — One page a content loader returns.
  • ContentExcerpt — How a content loader produces excerpts: true for the default, a separator string, or a function that fills excerpt of the parsed file.
  • ContentExcerptFile — A parsed Markdown file given to a custom excerpt function.
  • ContentLoader — The loader createContentLoader returns. It is a loader with watch, and its load() can also be called without arguments.
  • ContentLoaderOptions — Options of createContentLoader.
  • 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 with watch.
  • DataLoaderConfig — Facts about the site that a loader can use: its root, source and public folders, and the site data.
  • DataLoaderContext — What load() 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.ts file and import it from pages and layouts.
  • TrackedDataLoader — Recommended form: no watch, load() receives the context.
  • WatchDataLoader — VitePress-compatible form: load() receives the files watch matches, 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 of createMarkdownRenderer.
  • 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 typed unknown. 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: its titleTemplate applied to the page title, or Page 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 — Reads title, description and titleTemplate from frontmatter. Without a title, 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. root owns 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. Returning false cancels it; returning nothing (or true) lets it through. There is no redirect: a guard that wants another URL calls router.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 site base. External URLs and # anchors are returned as they are.
  • withoutBase — Takes the site base off a path, or returns undefined when the path is not under it.
  • 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 its href or target.
  • 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 way findDeadLinks does.
  • 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 dark must 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 names label in 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 problem validate() of a Standard Schema found.
  • StandardSchemaProps — The ~standard property of a Standard Schema.
  • StandardSchemaResult — What validate() 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 ~standard property, so a site can use any of them.

Comments