Documentation
¶
Overview ¶
Package external loads declarative disk-based plugins from {project}/plugins/{slug}/. Each plugin ships a plugin.yaml manifest describing conditional asset injection, output copying, and optional template contributions (partials, components, shortcodes). No code execution is involved: the engine synthesizes hook functions from the manifest and registers them with the regular plugin manager.
Index ¶
- func DirectiveDirs(projectDir string) []string
- func DiscoverDirs(projectDir string) []string
- func DiscoverSlugs(projectDir string) []string
- func LoadAll(mgr *plugin.Manager, projectDir string, cfg *config.SiteConfig, ...) (templateDirs, directiveDirs []string, warnings []engine.ValidationWarning)
- func LoadDefaults(dir string) (map[string]any, error)
- func Remove(projectDir, slug string) error
- func ValidSlug(s string) bool
- type BlueprintField
- type InjectConfig
- type Manifest
- type OutputConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DirectiveDirs ¶ added in v1.2.0
DirectiveDirs returns the directives/ directories of every plugin present under {projectDir}/plugins, regardless of enablement or licensing. It is the lightweight discovery used by CLI tools that do not resolve full config; LoadAll applies the disabled-list and license gating for builds.
func DiscoverDirs ¶
DiscoverDirs returns the absolute paths of plugin directories containing a plugin.yaml, in sorted (directory listing) order. Dot-directories are skipped.
func DiscoverSlugs ¶
DiscoverSlugs returns the names of directories under {projectDir}/plugins that contain a plugin.yaml. It is deliberately cheap (no YAML parsing) so it can run before config resolution to extend the known plugin name list.
func LoadAll ¶
func LoadAll(mgr *plugin.Manager, projectDir string, cfg *config.SiteConfig, reserved []string) (templateDirs, directiveDirs []string, warnings []engine.ValidationWarning)
LoadAll discovers, validates, and registers every external plugin found under {projectDir}/plugins. External plugins are enabled by presence on disk; slugs listed in plugins.disabled are skipped. reserved holds plugin names already taken by built-in, subpackage, and client-side plugins.
Each plugin is handled independently: a malformed manifest, a reserved slug, or a failed premium license check produces a warning and skips only that plugin. Returns the templates/ directories of active plugins (for the template overlay chain), their directives/ directories (for the generic directive overlay chain), and the accumulated warnings.
func LoadDefaults ¶
LoadDefaults resolves a plugin's shipped default config: blueprint.yaml field defaults overlaid by the flat key/value map in config.yaml. Either file may be absent. User overrides from sarde.yaml plugins.config.{slug} are applied later, at hook time, by the plugin manager.
Types ¶
type BlueprintField ¶
type BlueprintField struct {
Name string `json:"name"`
Type string `json:"type"`
Label string `json:"label"`
Hint string `json:"hint"`
Default any `json:"default"`
Min *float64 `json:"min,omitempty"`
Max *float64 `json:"max,omitempty"`
}
BlueprintField describes one configurable field declared in blueprint.yaml. Consumed by the desktop app for a future plugin settings UI.
func LoadBlueprint ¶
func LoadBlueprint(dir string) ([]BlueprintField, error)
LoadBlueprint parses {dir}/blueprint.yaml into field metadata. A missing file yields (nil, nil).
type InjectConfig ¶
type InjectConfig struct {
When string `yaml:"when"`
Layout string `yaml:"layout"`
Collection string `yaml:"collection"`
Styles []string `yaml:"styles"`
Scripts []string `yaml:"scripts"`
ModuleScripts []string `yaml:"module_scripts"`
}
InjectConfig declares conditional per-page asset injection.
func (*InjectConfig) HasAssets ¶
func (i *InjectConfig) HasAssets() bool
HasAssets reports whether the inject block references any asset files.
type Manifest ¶
type Manifest struct {
Name string `yaml:"name"`
Slug string `yaml:"slug"`
Version string `yaml:"version"`
Description string `yaml:"description"`
Author string `yaml:"author"`
Homepage string `yaml:"homepage"`
Premium bool `yaml:"premium"`
PurchaseURL string `yaml:"purchase_url"`
Inject InjectConfig `yaml:"inject"`
Output OutputConfig `yaml:"output"`
}
Manifest is the parsed plugin.yaml of one external plugin.
func Install ¶
Install fetches a plugin from source (local zip, local directory, GitHub repository, or zip/tar.gz URL), validates its manifest in a staging directory, and moves it into {projectDir}/plugins/{slug}/. The destination directory name always equals the manifest slug; there is no name override because license lookup and enable/disable both key off the slug. reserved holds built-in plugin names that external slugs may not use.
func LoadManifest ¶
LoadManifest reads and parses {dir}/plugin.yaml. Unknown fields are rejected so manifest typos surface as errors instead of silent no-ops.
func (*Manifest) EffectivePrefix ¶
EffectivePrefix returns the dist-relative output prefix, always without a leading slash and with a trailing slash. Defaults to assets/vendor/{slug}/ with underscores kebab-ized: identifiers are snake_case, URLs are kebab-case, and underscores never appear in an emitted URL.
func (*Manifest) IncludeFilter ¶
IncludeFilter returns a filter for WriteFSTreeFiltered based on output.include, or nil when the whole assets/ tree should be copied. Entries ending in "/" match directory prefixes; other entries match the exact file or a directory of that name.
type OutputConfig ¶
OutputConfig declares which files under assets/ are copied to dist and where.