processor

package
v1.0.21 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package processor builds dependency graphs and processes articles for output.

Package processor builds dependency graphs and taxonomies from parsed articles.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildCategoryIndex

func BuildCategoryIndex(articles []*model.ProcessedArticle) map[string][]*model.ProcessedArticle

BuildCategoryIndex returns a map from category name to the articles that use it.

func BuildTagIndex

func BuildTagIndex(articles []*model.ProcessedArticle) map[string][]*model.ProcessedArticle

BuildTagIndex returns a map from tag name to the articles that use that tag.

func CalculateDiff

func CalculateDiff(oldGraph, newGraph *model.DependencyGraph) (*model.ChangeSet, error)

CalculateDiff compares two dependency graphs and returns a ChangeSet describing added, deleted, and modified nodes.

func CalculateImpact

func CalculateImpact(g *model.DependencyGraph, changedPath string) []string

CalculateImpact returns all node paths that are transitively impacted when changedPath changes (i.e., changedPath plus all its transitive dependents).

func LoadLocaleAwareTaxonomyRegistries added in v1.0.6

func LoadLocaleAwareTaxonomyRegistries(contentDir string, locales []string) (map[string]*model.TaxonomyRegistry, error)

LoadLocaleAwareTaxonomyRegistries loads a taxonomy registry per locale. For each locale it looks for {contentDir}/{locale}/tags.yaml (and categories.yaml), falling back to the global {contentDir}/tags.yaml when the locale file is absent. The returned map also has an "" (empty string) key holding the global registry.

func LoadTaxonomyRegistry

func LoadTaxonomyRegistry(taxonomyDir string) (*model.TaxonomyRegistry, error)

LoadTaxonomyRegistry reads tags.yaml and categories.yaml from taxonomyDir and returns the combined TaxonomyRegistry. Missing files are treated as empty (no error).

func MergeTaxonomyRegistries added in v1.0.6

func MergeTaxonomyRegistries(registries map[string]*model.TaxonomyRegistry) *model.TaxonomyRegistry

MergeTaxonomyRegistries returns a single registry that is the deduplicated union of all registries in the map. Useful for populating site.Tags/Categories.

func ValidateArticleTaxonomies

func ValidateArticleTaxonomies(articles []*model.ProcessedArticle, registry *model.TaxonomyRegistry) []error

ValidateArticleTaxonomies checks that every tag and category referenced in an article exists in the registry. It returns one error per violation.

func ValidateArticleTaxonomiesLocale added in v1.0.6

func ValidateArticleTaxonomiesLocale(articles []*model.ProcessedArticle, registries map[string]*model.TaxonomyRegistry) []error

ValidateArticleTaxonomiesLocale validates each article against its locale's registry from the registries map. Falls back to the "" key when no locale-specific registry is found. Only validates when the registry has entries.

func ValidateOutputPaths added in v0.1.2

func ValidateOutputPaths(articles []*model.ProcessedArticle) []error

ValidateOutputPaths checks that no two articles resolve to the same output path, which would cause one page to silently overwrite the other during HTML generation. It returns one error per duplicate pair.

Types

type Processor

type Processor interface {
	// Process converts a slice of Articles into ProcessedArticles, rendering
	// Markdown to HTML, extracting summaries, resolving output paths, etc.
	Process(articles []*model.Article, cfg model.Config) ([]*model.ProcessedArticle, error)

	// BuildDependencyGraph constructs the full DependencyGraph from the
	// complete set of ProcessedArticles.
	BuildDependencyGraph(articles []*model.ProcessedArticle) (*model.DependencyGraph, error)

	// BuildTaxonomyRegistry collects all tags and categories referenced across
	// all articles and validates them against the configured taxonomy YAML files.
	BuildTaxonomyRegistry(articles []*model.ProcessedArticle, cfg model.Config) (*model.TaxonomyRegistry, error)

	// BuildTranslationMap links articles that share a TranslationKey by
	// populating their Translations field. Should be called after Process.
	BuildTranslationMap(articles []*model.ProcessedArticle)
}

Processor enriches raw Article data and builds the site-wide dependency graph and taxonomy registry that are required for incremental builds.

type SiteProcessor

type SiteProcessor struct{}

SiteProcessor implements the Processor interface.

func NewSiteProcessor

func NewSiteProcessor() *SiteProcessor

NewSiteProcessor returns a new SiteProcessor.

func (*SiteProcessor) BuildDependencyGraph

func (p *SiteProcessor) BuildDependencyGraph(articles []*model.ProcessedArticle) (*model.DependencyGraph, error)

BuildDependencyGraph constructs a DependencyGraph from all processed articles, linking each article to its tag, category, and archive (year) nodes.

func (*SiteProcessor) BuildTaxonomyRegistry

func (p *SiteProcessor) BuildTaxonomyRegistry(articles []*model.ProcessedArticle, cfg model.Config) (*model.TaxonomyRegistry, error)

BuildTaxonomyRegistry collects all unique tags and categories referenced across the article set and returns a TaxonomyRegistry.

func (*SiteProcessor) BuildTranslationMap

func (p *SiteProcessor) BuildTranslationMap(articles []*model.ProcessedArticle)

BuildTranslationMap populates the Translations field of each ProcessedArticle that has a TranslationKey set, linking it to sibling articles in other locales. Call this once after all articles have been processed.

func (*SiteProcessor) Process

func (p *SiteProcessor) Process(articles []*model.Article, cfg model.Config) ([]*model.ProcessedArticle, error)

Process converts raw Articles into ProcessedArticles by rendering Markdown to HTML, extracting summaries, and computing output paths.

Jump to

Keyboard shortcuts

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