package segments

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

Index

Functions

func DecodeSegments

func DecodeSegments(in map[string]any, segmentsToRender []string, logger loggers.Logger) (*config.ConfigNamespace[map[string]SegmentConfig, *Segments], error)

Types

type SegmentConfig

type SegmentConfig struct {
	Excludes []SegmentMatcherFields
	Includes []SegmentMatcherFields
}

type SegmentFilter

type SegmentFilter interface {
	// ShouldExcludeCoarse returns whether the given fields should be excluded on a coarse level.
	ShouldExcludeCoarse(SegmentQuery) bool

	// ShouldExcludeFine returns whether the given fields should be excluded on a fine level.
	ShouldExcludeFine(SegmentQuery) bool
}

type SegmentMatcherFields

type SegmentMatcherFields struct {
	Kind   []string
	Path   []string
	Output []string
	Lang   string            // Deprecated: use Sites.Matrix instead.
	Sites  sitesmatrix.Sites // Note that we only use Sites.Matrix for now.
}

SegmentMatcherFields holds string slices of ordered filters for segment matching. The Glob patterns can be negated by prefixing with "! ". The first match wins (either include or exclude).

type SegmentQuery

type SegmentQuery struct {
	Kind   string
	Path   string
	Output string
	Site   sitesmatrix.Vector
}

type Segments

type Segments struct {

	// SegmentFilter is the compiled filter for all segments to render.
	SegmentFilter SegmentFilter
	// contains filtered or unexported fields
}

Segments is a collection of named segments.

func (*Segments) InitConfig

func (b *Segments) InitConfig(logger loggers.Logger, _ sitesmatrix.VectorStore, configuredDimensions *sitesmatrix.ConfiguredDimensions) error

Source Files

segments.go

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

Tools for package owners.