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 #
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
The resolved site config that configResolved() received.
Absolute path of the site root, the folder of kawapress.config.ts.
Site title.
Description of pages that set none in frontmatter or locale config.
Deploy path, always starting and ending with /.
Markdown source folder, relative to root.
Glob patterns, relative to srcDir, of Markdown files that are not pages.
The rules that move pages to other routes, if any.
Public folder, relative to srcDir.
Tags added to the <head> of every page.
Theme settings.
Every locale; a site without locales has an English root locale.
Called each time the pages change.
Returns A function that stops the notifications.
Notes #
site is the object configResolved() received.
Full type signature
function onSitePagesChange(site: ResolvedSiteConfig, listener: () => void): () => void

Comments