Plugin Lifecycle
Load Phase
Before build execution, PluginRegistry.load() in core/registries/pluginRegistry.js:
- Resolves the package path from the project root using
exec.resolve(). - Dynamically imports the plugin module.
- Validates the plugin object: must be a non-null object with a non-empty
namestring. - Rejects duplicates by
name. - Caches in a
Map<string, PluginInstance>. - If the plugin has a
load(ctx)function, calls it with{ config, paths }.
Build Hook Phase
During the build (core/scripts/build.js), hooks execute in this fixed order:
dist:clean-dist/has been cleared and recreated. Generate files that need to exist before content processing.assets:copy- Static assets have been copied. Run asset pipelines (CSS/JS compilation).content:load- Markdown files have been loaded intoContentRegistry. Inject additional content viactx.addContent().content:ready- Collections (tags, categories, series) have been built. Generate files based on the full content set (RSS, sitemap).
Page Meta Phase
page:meta is triggered from buildPageMetaWithPlugins() during page rendering. It runs once per content file and receives:
frontMatter- the page's front matter objectderivedFrontMatter- enriched front matterlang,slug- page identitypageMeta- current metadata (mutable)setPageMeta(meta)- callback to replace page metadatapages- full collection data
Execution Order Within Hooks
Plugins are iterated in the order they appear in the plugins config array. The PluginEngine iterates the Map via for...of, preserving insertion order.
Hook Context Summary
| Hook | contentFiles | addContent | pages | footerPolicies | contentIndex | frontMatter | setPageMeta |
|---|---|---|---|---|---|---|---|
dist:clean | - | - | - | - | - | - | - |
assets:copy | - | - | - | - | - | - | - |
content:load | ✓ | ✓ | - | - | - | - | - |
content:ready | ✓ | - | ✓ | ✓ | ✓ | - | - |
page:meta | - | - | via runtime | - | - | ✓ | ✓ |
Failure Semantics
- A
throwinside a hook handler is caught byPluginEngine.execute(). - The error is logged via
log.err(). - The remaining plugins for that hook continue executing.
- The build continues to the next stage.
This means a single plugin failure does not break the build, but plugin output may be incomplete.