Help us shape the future of Go! Take the 2026 Go Developer Survey

pattern

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Overview

Package pattern is the site-layout pattern system: declarative packages that layer opinionated page templates above the active theme identity. Themes stay type/color/spacing; patterns are magazine/company/portfolio- style layouts selectable independently. See docs/PATTERN-PLUGINS.md.

Index

Constants

View Source
const EnvPatternsDir = "GORUN_PATTERNS"

EnvPatternsDir names the environment variable that points at the ship-with patterns directory.

View Source
const EnvPatternsExtra = "GORUN_PATTERNS_EXTRA"

EnvPatternsExtra lists extra pattern roots (PATH-separated), searched after the core directory. Operator-installed packages under DataDir/patterns win over ship-with packages of the same slug.

View Source
const SettingPattern = "site.pattern"

SettingPattern stores the active layout pattern slug (empty = none).

Variables

View Source
var (
	// ErrNotFound is returned for unknown pattern slugs.
	ErrNotFound = errors.New("pattern: not found")
	// ErrInvalid is returned for a broken pattern package.
	ErrInvalid = errors.New("pattern: invalid")
)

Functions

func ExtraPatternsDirs

func ExtraPatternsDirs() []string

ExtraPatternsDirs returns directories listed in $GORUN_PATTERNS_EXTRA.

func PatternsDir

func PatternsDir(cfg config.Config) string

PatternsDir returns the core patterns directory.

Types

type Info

type Info struct {
	Slug        string            `json:"slug"`
	Version     string            `json:"version"`
	Name        map[string]string `json:"name"`
	Description map[string]string `json:"description"`
	Dir         string            `json:"dir"`
	Bundled     bool              `json:"bundled"`
}

Info is a discovered pattern package.

func (Info) DisplayDescription

func (i Info) DisplayDescription(locale string) string

DisplayDescription picks a localized description.

func (Info) DisplayName

func (i Info) DisplayName(locale string) string

DisplayName picks a localized label.

type Module

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

Module is the pattern kernel.Module.

func New

func New(opts ...Option) *Module

New returns the pattern module.

func (*Module) Catalogs

func (*Module) Catalogs() fs.FS

Catalogs implements kernel.CatalogProvider.

func (*Module) Migrations

func (*Module) Migrations() fs.FS

Migrations implements kernel.Module (settings key only).

func (*Module) Name

func (*Module) Name() string

Name implements kernel.Module.

func (*Module) Register

func (m *Module) Register(d *kernel.Deps) error

Register publishes the service, wires the theme pattern layer, admin UI and public pattern assets.

type Option

type Option func(*Module)

Option configures the module.

func WithPatternsDir

func WithPatternsDir(dir string) Option

WithPatternsDir sets the ship-with patterns directory.

type Service

type Service interface {
	List(ctx context.Context) ([]Info, error)
	Lookup(slug string) (Info, error)
	ActiveInfo(ctx context.Context) (Info, bool)
	Activate(ctx context.Context, slug string) error
	Clear(ctx context.Context) error
}

Service manages layout pattern packages.

Jump to

Keyboard shortcuts

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