plugin

package
v0.1.15 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package plugin defines the gohan plugin interface and built-in plugin registry.

Plugins are compiled into the gohan binary and enabled/disabled via config.yaml:

plugins:
  amazon_books:
    enabled: true
    tag: "your-associate-tag-22"

Each plugin receives a ProcessedArticle and its own config section, and returns arbitrary data that the theme template can access via .PluginData.<plugin_name>.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Plugin

type Plugin interface {
	// Name returns the unique identifier of the plugin.
	// This key is used in config.yaml under plugins.<name>
	// and as the key in ProcessedArticle.PluginData.
	Name() string

	// Enabled reports whether the plugin is active for the given config section.
	// cfg is the map under plugins.<name> in config.yaml.
	Enabled(cfg map[string]interface{}) bool

	// TemplateData returns data to inject into the template context for the
	// given article. The returned map is stored at .PluginData.<name> in
	// the template.
	TemplateData(article *model.ProcessedArticle, cfg map[string]interface{}) (map[string]interface{}, error)
}

Plugin is the interface that all gohan plugins must implement.

type Registry

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

Registry holds the set of built-in plugins.

func DefaultRegistry

func DefaultRegistry() *Registry

DefaultRegistry returns a Registry pre-loaded with all built-in plugins.

func (*Registry) Enrich

func (r *Registry) Enrich(site *model.Site) error

Enrich runs all enabled plugins over every article in site, populating article.PluginData with each plugin's output. Call this after processing articles and before generating HTML.

Directories

Path Synopsis
Package amazonbooks is a gohan built-in plugin that generates Amazon book cards for article templates.
Package amazonbooks is a gohan built-in plugin that generates Amazon book cards for article templates.

Jump to

Keyboard shortcuts

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