onSitePagesChange #

Calls listener when the pages of a site changed: a Markdown file was added or removed, or a file a plugin's pages() group depends on changed the pages it produces. Only the dev server reports changes. Returns the function that stops the notifications.

Usage #

TypeScript
import { 
definePlugin
} from 'kawapress'
import {
onSitePagesChange
} from 'kawapress/generator'
export default
definePlugin
({
name
: 'watch-pages',
setup
(
api
) {
api
.
configResolved
((
site
) => {
onSitePagesChange
(
site
, () =>
console
.
log
('changed'))
}) }, })

Parameters

siteResolvedSiteConfig

The resolved site config that configResolved() received.

rootstring

Absolute path of the site root, the folder of kawapress.config.ts.

titlestring

Site title.

descriptionoptionalstring

Description of pages that set none in frontmatter or locale config.

basestring

Deploy path, always starting and ending with /.

srcDirstring

Markdown source folder, relative to root.

srcExcludereadonly string[]

Glob patterns, relative to srcDir, of Markdown files that are not pages.

rewritesPageRewrites | undefined

The rules that move pages to other routes, if any.

publicDirstring

Public folder, relative to srcDir.

headreadonly HeadConfig[]

Tags added to the <head> of every page.

themeConfigReadonly<Partial<ThemeConfig>>

Theme settings.

localesReadonly<Record<string, LocaleConfig>>

Every locale; a site without locales has an English root locale.

listener(): void

Called each time the pages change.

Returns A function that stops the notifications.

Notes #

site is the object configResolved() received.

Full type signature
TypeScript
function onSitePagesChange(site: ResolvedSiteConfig, listener: () => void): () => void

Edit this page

Comments