package roles

import "github.com/gohugoio/hugo/hugolib/roles"

Index

Functions

func DecodeConfig

func DecodeConfig(defaultContentRole string, m map[string]any) (*config.ConfigNamespace[map[string]RoleConfig, RolesInternal], string, error)

Types

type Role

type Role interface {
	Name() string
}

func NewRole

func NewRole(r RoleInternal) Role

type RoleConfig

type RoleConfig struct {
	// The weight of the role.
	// Used to determine the order of the roles.
	// If zero, we use the role name.
	Weight int
}

type RoleInternal

type RoleInternal struct {
	// Name is the name of the role, extracted from the key in the config.
	Name string

	// Whether this role is the default role.
	// This will be rendered in the root.
	// There is only be one default role.
	Default bool

	RoleConfig
}

type Roles

type Roles []Role

type RolesInternal

type RolesInternal struct {
	Sorted []RoleInternal
	// contains filtered or unexported fields
}

func (RolesInternal) ForEachIndex

func (r RolesInternal) ForEachIndex() iter.Seq[int]

ForEachIndex returns an iterator for the indices of the roles.

func (RolesInternal) Has

func (r RolesInternal) Has(role string) bool

func (RolesInternal) IndexDefault

func (r RolesInternal) IndexDefault() int

func (RolesInternal) IndexMatch

func (r RolesInternal) IndexMatch(match predicate.P[string]) (iter.Seq[int], error)

IndexMatch returns an iterator for the roles that match the filter.

func (RolesInternal) Len

func (r RolesInternal) Len() int

func (RolesInternal) ResolveIndex

func (r RolesInternal) ResolveIndex(name string) int

func (RolesInternal) ResolveName

func (r RolesInternal) ResolveName(i int) string

Source Files

roles.go

Version
v0.153.4 (latest)
Published
Dec 28, 2025
Platform
linux/amd64
Imports
9 packages
Last checked
4 months ago

Tools for package owners.