Documentation
¶
Overview ¶
Package clientplugins provides a declarative manifest-driven loader for client-side plugins. Instead of separate Go subpackages, all pure JS/CSS plugins are defined in manifest.yaml with inject_when rules, and their assets are embedded via go:embed.
Index ¶
- func Defaults(slug string) map[string]any
- func Description(slug string) string
- func FieldNames(slug string) []string
- func Fields(slug string) []cfgutil.Field
- func Initialize() error
- func Label(slug string) string
- func PluginSlugs() []string
- func RegisterAll(mgr *plugin.Manager, enabled []string, configs map[string]map[string]any, ...)
- type Manifest
- type ManifestEntry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Description ¶ added in v1.4.0
Description returns the manifest description of a plugin, or "".
func FieldNames ¶ added in v1.2.0
FieldNames returns the declared config field names of a plugin, sorted, or nil for a plugin the manifest does not know or that ships no defaults file.
func Fields ¶ added in v1.4.0
Fields returns a plugin's typed config field specs (sorted by name), or nil for a plugin the manifest does not know or that ships no defaults file.
func Initialize ¶
func Initialize() error
Initialize loads the embedded plugin manifest and per-plugin defaults. Safe to call multiple times; only the first call does work.
Bundling deliberately does not happen here: which plugins belong in the bundle depends on the site's plugins.enabled, and Initialize runs during config resolution (see build.KnownPluginNames), before any config exists. RegisterAll builds the bundle instead, once the enabled set is known.
func PluginSlugs ¶
func PluginSlugs() []string
PluginSlugs returns the slugs of all plugins defined in the manifest.
func RegisterAll ¶
func RegisterAll(mgr *plugin.Manager, enabled []string, configs map[string]map[string]any, assetDir string)
RegisterAll registers a single "clientplugins" meta-plugin that injects the bundled CSS/JS on every page and per-plugin config scripts gated by inject_when.
Only plugins named in enabled contribute to the bundle, so a site ships no code for plugins it has not turned on. assetDir overrides the embedded assets for 'sarde dev --theme-dev'; empty means use the embedded ones.
Types ¶
type Manifest ¶
type Manifest struct {
Plugins map[string]ManifestEntry `yaml:"plugins"`
}
Manifest holds all client plugin definitions.
type ManifestEntry ¶
type ManifestEntry struct {
Label string `yaml:"label"`
Description string `yaml:"description"`
InjectWhen string `yaml:"inject_when"`
Assets struct {
CSS string `yaml:"css"`
JS string `yaml:"js"`
} `yaml:"assets"`
Module bool `yaml:"module"`
}
ManifestEntry defines a single client-side plugin in the manifest.