taxonomy

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package taxonomy aggregates tags, categories, and other taxonomies across all pages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildTaxonomies

func BuildTaxonomies(pages []*engine.Page, taxCfg map[string]config.TaxonomyConfig, lang string) (map[string]*engine.Taxonomy, []string)

BuildTaxonomies walks all pages and aggregates taxonomy terms. Returns a map of taxonomy name → Taxonomy (e.g., "tags", "categories"). The taxCfg map drives which taxonomies are built; if nil or empty, defaults to tags + categories for backward compatibility.

lang scopes aggregation to a single language: when non-empty, pages whose Lang is set and differs from lang are skipped. This prevents a translated post (and its generated fallbacks) from being counted once per language on the same term page — taxonomy pages render once, at the default-language URLs. Pass "" to include every page (single-language sites, where Lang is empty).

The second return value is a list of warnings collected while adding terms (e.g. two differently-named terms colliding on the same slug).

func ComputeTermEntries

func ComputeTermEntries(tax *engine.Taxonomy) []*engine.TermEntry

ComputeTermEntries builds a sorted slice of TermEntry with popularity tiers. Hidden terms are excluded. Sort order: Priority desc, Count desc, Name asc.

func EnrichTaxonomies

func EnrichTaxonomies(
	taxonomies map[string]*engine.Taxonomy,
	taxCfg map[string]config.TaxonomyConfig,
	projectDir string,
	lang string,
) ([]string, error)

EnrichTaxonomies applies term metadata from data/*.yml, validates undefined tags per the configured strictness mode, and sorts term pages by date. When lang is non-empty, per-language overlays (data/<name>.<lang>.yml) are loaded on top of the base file. Returns a list of warnings and an error (for "error" strictness mode).

func LoadTermMetadata

func LoadTermMetadata(projectDir, taxonomyName string) (map[string]TermMetadata, error)

LoadTermMetadata reads data/<taxonomyName>.yml from the project data dir. Returns a map of slug to TermMetadata. A missing file returns nil, nil.

func LoadTermMetadataForLang

func LoadTermMetadataForLang(projectDir, taxonomyName, lang string) (map[string]TermMetadata, error)

LoadTermMetadataForLang loads term metadata with per-language overlay. Resolution order per term: base entry → inline translations[lang] → file overlay. lang=="" returns base only (with Translations stripped).

Types

type TermMetadata

type TermMetadata struct {
	Label        string                     `yaml:"label"`
	Description  string                     `yaml:"description"`
	Color        string                     `yaml:"color"`
	Icon         string                     `yaml:"icon"`
	Hidden       bool                       `yaml:"hidden"`
	Priority     int                        `yaml:"priority"`
	Permalink    string                     `yaml:"permalink"`
	Difficulty   string                     `yaml:"difficulty"`
	ContentType  string                     `yaml:"content_type"`
	Translations map[string]TermTranslation `yaml:"translations"`
}

TermMetadata holds optional per-term configuration from data/<taxonomy>.yml.

type TermTranslation

type TermTranslation struct {
	Label       string `yaml:"label"`
	Description string `yaml:"description"`
}

TermTranslation holds the translatable fields for a single language inside a term's inline translations: block.

Jump to

Keyboard shortcuts

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