Expand description
Lifecycle hook plugin system.
§Plugin architecture for SSG
Provides a trait-based plugin system with lifecycle hooks for extending the static site generation pipeline.
§Lifecycle hooks
Plugins can hook into three stages of site generation:
before_compile— Runs before compilation. Use for content preprocessing, metadata injection, or source transformation.after_compile— Runs after compilation. Use for HTML post-processing, asset optimization, or sitemap generation.on_serve— Runs before the dev server starts. Use for injecting dev-mode scripts or live-reload support.
§Example
use ssg::plugin::{Plugin, PluginContext};
use anyhow::Result;
#[derive(Debug)]
struct MinifyPlugin;
impl Plugin for MinifyPlugin {
fn name(&self) -> &str { "minify" }
fn after_compile(&self, ctx: &PluginContext) -> Result<()> {
println!("Minifying files in {:?}", ctx.site_dir);
// Walk site_dir and minify HTML/CSS/JS files
Ok(())
}
}Structs§
- Plugin
Cache - Content-addressed cache that tracks file hashes so plugins can skip unchanged files across incremental builds.
- Plugin
Context - Context passed to plugin hooks with paths and configuration.
- Plugin
Manager - Manages registered plugins and executes lifecycle hooks.
Traits§
- Plugin
- Trait for SSG plugins.