clientplugins

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 25, 2026 License: MIT Imports: 15 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Defaults

func Defaults(slug string) map[string]any

Defaults returns the default config values for a plugin, or nil if unknown.

func Initialize

func Initialize() error

Initialize loads the embedded plugin manifest and pre-computes bundles. Safe to call multiple times; only the first call does work.

func PluginSlugs

func PluginSlugs() []string

PluginSlugs returns the slugs of all plugins defined in the manifest.

func RecomputeFromDir

func RecomputeFromDir(dir string) error

RecomputeFromDir reloads and rebundles all plugin client assets from the given filesystem directory. For use by 'sarde dev --theme-dev' only.

func RegisterAll

func RegisterAll(mgr *plugin.Manager, enabled []string, configs map[string]map[string]any)

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.

Types

type Manifest

type Manifest struct {
	Plugins map[string]ManifestEntry `yaml:"plugins"`
}

Manifest holds all client plugin definitions.

type ManifestEntry

type ManifestEntry struct {
	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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL