plugin

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hook

type Hook struct {
	Name  string
	Point HookPoint
	Fn    func(ctx *HookContext) error
}

Hook is a function called at a specific point in processing.

type HookConfig

type HookConfig struct {
	Point   string        `yaml:"point"`
	Command string        `yaml:"command"`
	Prepend string        `yaml:"prepend"`
	Append  string        `yaml:"append"`
	Replace []ReplaceRule `yaml:"replace"`
}

HookConfig defines a hook in a YAML plugin file.

type HookContext

type HookContext struct {
	FilePath string
	Content  string
	Metadata map[string]interface{}
	Theme    string
	Width    int
	Format   string
}

HookContext provides data to hook functions.

type HookPoint

type HookPoint int

HookPoint identifies when a plugin hook fires.

const (
	HookBeforeRender HookPoint = iota
	HookAfterRender
	HookBeforeIndex
	HookAfterIndex
	HookOnNavigate
)

type PluginConfig

type PluginConfig struct {
	Name        string       `yaml:"name"`
	Description string       `yaml:"description"`
	Hooks       []HookConfig `yaml:"hooks"`
}

PluginConfig represents a YAML plugin definition.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry manages registered plugin hooks.

func LoadPlugins

func LoadPlugins(configDir string) (*Registry, error)

LoadPlugins scans configDir for .yaml plugin definitions and registers their hooks.

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates an empty plugin registry.

func (*Registry) Register

func (r *Registry) Register(hook Hook)

Register adds a hook at the specified point.

func (*Registry) Run

func (r *Registry) Run(point HookPoint, ctx *HookContext) error

Run executes all hooks registered at the given point. For HookBeforeRender, the Content field may be modified by hooks.

type ReplaceRule

type ReplaceRule struct {
	Old string `yaml:"old"`
	New string `yaml:"new"`
}

ReplaceRule defines a string replacement in content.

Jump to

Keyboard shortcuts

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