setupGeneratorPlugins #

Sets up the plugins of a site config the way kawapress build does: runs each plugin's setup(), config() and configResolved() with KawaPress's own defaults and checks. Plugin tests and tools drive the other hooks through the returned host instead of imitating the plugin API.

Usage #

TypeScript
import { 
definePlugin
} from 'kawapress'
import {
setupGeneratorPlugins
} from 'kawapress/generator'
const
plugin
=
definePlugin
({
name
: 'demo',
setup
() {} })
const
host
= await
setupGeneratorPlugins
({
plugins
: [
plugin
] })
console
.
log
(
host
.
site
.
title
)

Parameters

configKawapressConfig

The site config, with the plugins to set up.

titleoptionalstring

Site title, shown in the browser tab and used by themes.

descriptionoptionalstring

<meta name="description"> of pages that set no description in frontmatter. A locale's own description takes precedence.

baseoptionalstring

URL prefix the site is served under, for example /docs/. Defaults to /.

srcDiroptionalstring

Folder with the Markdown files, relative to the site root. Defaults to the site root.

srcExcludeoptionalstring[]

Glob patterns, relative to srcDir, of Markdown files that are not pages, for example snippets/** for a folder of shared parts.

rewritesoptionalPageRewrites

Moves pages to other routes without moving their files, for example { 'packages/:pkg/src/:page*': ':pkg/:page*' }.

publicDiroptionalstring

Folder of static files copied as they are, relative to the site root. Defaults to public.

headoptionalHeadConfig[]

Tags added to the <head> of every page.

themeConfigoptionalPartial<ThemeConfig>

Settings for the theme.

localesoptionalRecord<string, LocaleConfig>

The languages of the site, by key. The root key is the language served at /.

pluginsoptionalKawaPressPlugin[]

Plugins of the site, run in order.

viteoptionalUserConfig

Extra Vite configuration, merged before plugin vite() hooks run.

runtimePluginoptionalstring

A site-local Runtime Plugin module, relative to the site root.

deadLinksoptionalfalse | DeadLinkConfig

Internal link checking. Defaults to { level: 'error' }; false disables it.

frontmatteroptionalfalse | FrontmatterConfig

Frontmatter checking: rules for the site's own keys, and whether a page that breaks a rule fails the build. Defaults to { level: 'error' }; false turns the check off.

optionsoptionalResolveSiteConfigOptions

The site root, and whether the dev server runs.

default {}

Returns The host that runs the remaining hooks.

Full type signature
TypeScript
function setupGeneratorPlugins(
  config: KawapressConfig,
  options?: ResolveSiteConfigOptions,
): Promise<GeneratorPluginHost>

Edit this page

Comments