addPageComponent #
Declares that the page being rendered uses component.
Usage #
import { addPageComponent } from 'kawapress'
const env = {}
addPageComponent(env, { name: 'AcmeChart', from: 'acme/chart' })Parameters
The Markdown env of the rule that produced the tag.
Public route of the page being rendered. Only used in error messages.
The components the page has declared so far. KawaPress reads them after rendering.
The Markdown env of markdown-it and markdown-exit carries every value a
plugin writes. Accepting that shape here lets a plugin pass the env it
receives straight to addPageComponent().
The tag name and the module that provides it.
Name of the tag in the page template, for example AcmeChart in
<AcmeChart />. It becomes the import binding of the page SFC, so it must
be a valid JavaScript identifier.
Module whose default export is the component: a bare package specifier or an absolute file path. Vite resolves it from the page that imports it.
Notes #
Call it with the env of the rule that produced the tag. Declaring the same name and module twice is harmless, because a page can render a component many times; declaring the same name from two modules is an error.
Full type signature
function addPageComponent(env: PageComponentEnv, component: PageComponent): void

Comments