segments

package
v0.154.1 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2026 License: Apache-2.0 Imports: 11 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

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 added in v0.153.0

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 added in v0.153.0

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