collection

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyCascade

func ApplyCascade(pages []*engine.Page)

ApplyCascade resolves frontmatter inheritance from section _index.md pages. Each section's `cascade` map is applied to all descendant pages that don't explicitly set those fields. Must be called after BuildSectionTree.

func BuildCollections

func BuildCollections(
	files []content.ContentFile,
	siteCfg *config.SiteConfig,
	contentDir string,
) (map[string]*engine.Collection, []engine.ValidationWarning, error)

BuildCollections groups discovered files into typed collections, builds Pages, applies sorting, section trees, draft filtering, and prev/next wiring. Returns the collections map and any validation warnings.

func BuildCollectionsWithOptions

func BuildCollectionsWithOptions(
	files []content.ContentFile,
	siteCfg *config.SiteConfig,
	contentDir string,
	opts BuildOptions,
) (map[string]*engine.Collection, []engine.ValidationWarning, error)

BuildCollectionsWithOptions groups discovered files into typed collections with optional parallel parsing.

func BuildCompositeNavTrees

func BuildCompositeNavTrees(col *engine.Collection, langs []string) map[string]*engine.NavTree

BuildCompositeNavTrees builds one NavTree per (lang, version) pair found in the collection's pages. Keyed by LangVersionKey. Used for versioned collections that may also be multi-language.

func BuildCompositeTabSets

func BuildCompositeTabSets(col *engine.Collection, contentDir string, langs []string) map[string][]*engine.DocsTab

BuildCompositeTabSets builds one tab set per (lang, version) pair found in the collection's pages. Used for collections with both versioning and tabs.

func BuildSectionTree

func BuildSectionTree(pages []*engine.Page, collectionName string) []*engine.Section

BuildSectionTree constructs a tree of Section nodes from pages. Pages with Kind==KindSection become section index pages. Other pages are assigned to their deepest matching section. Returns top-level sections for the collection.

func BuildSinglePage

func BuildSinglePage(
	cf content.ContentFile,
	contentDir string,
	collCfg *engine.CollectionConfig,
	schema *engine.FrontmatterSchema,
	summaryLength int,
	lastUpdatedStrategy string,
	taxCfg map[string]config.TaxonomyConfig,
) (*engine.Page, []engine.ValidationWarning, error)

BuildSinglePage parses, infers, and transforms a single ContentFile into a Page. Used by incremental rebuild to re-parse a changed file without rebuilding all collections.

func BuildStandalonePages

func BuildStandalonePages(
	files []content.ContentFile,
	contentDir string,
	summaryLength int,
	lastUpdatedStrategy string,
) ([]*engine.Page, error)

BuildStandalonePages builds Page objects for root-level files (home, standalone).

func BuildStandalonePagesWithOptions

func BuildStandalonePagesWithOptions(
	files []content.ContentFile,
	contentDir string,
	summaryLength int,
	lastUpdatedStrategy string,
	opts BuildOptions,
) ([]*engine.Page, error)

BuildStandalonePagesWithOptions builds root-level pages with optional parallel parsing.

func BuildTabs

func BuildTabs(col *engine.Collection, contentDir string) []*engine.DocsTab

BuildTabs creates DocsTab entries for a tabbed collection (single language).

func BuildTabsI18n

func BuildTabsI18n(col *engine.Collection, contentDir string, langs []string) []*engine.DocsTab

BuildTabsI18n creates DocsTab entries with per-language nav trees.

func DetectTabs

func DetectTabs(col *engine.Collection) bool

DetectTabs determines whether a collection should use tabbed docs mode. Returns true when: explicit config forces it, or auto-detection finds 2+ top-level sections all with _index.md and no loose root pages.

func FindTabForPage

func FindTabForPage(tabs []*engine.DocsTab, page *engine.Page) *engine.DocsTab

FindTabForPage returns the tab that contains the given page, or nil.

func InferCollection

func InferCollection(dirName string) *engine.CollectionConfig

InferCollection returns a CollectionConfig with sensible defaults based on the directory name convention.

func IsBlogName

func IsBlogName(name string) bool

IsBlogName returns true if the directory name maps to a blog-type collection.

func LangVersionKey

func LangVersionKey(lang, ver string) string

LangVersionKey computes the composite map key for a (lang, version) pair.

func LinkVersions

func LinkVersions(pages []*engine.Page)

LinkVersions groups pages across versions by their VersionRelPath and populates each page's VersionPeers slice, mirroring i18n.LinkTranslations.

func MergeCollectionConfig

func MergeCollectionConfig(inferred *engine.CollectionConfig, siteCfg *config.CollectionSiteConfig) *engine.CollectionConfig

MergeCollectionConfig overlays sarde.yaml collection values onto inferred defaults. Non-zero/non-nil site config values win over inferred values. Returns a new CollectionConfig (does not mutate the input).

func RebuildNavTreesWithFallbacks

func RebuildNavTreesWithFallbacks(collections map[string]*engine.Collection, allPages []*engine.Page, langs []string)

RebuildNavTreesWithFallbacks rebuilds per-language nav trees after fallback pages have been generated, so every language gets a complete sidebar (real translations + fallback pages from the default language).

func SortPages

func SortPages(pages []*engine.Page, sortBy, sortOrder string)

SortPages sorts pages in-place by the given key and order. Supported keys: "date", "order", "title", "slug". Order: "asc" or "desc" (defaults to "asc"). Uses stable sort to preserve filesystem order for ties.

func WirePrevNext

func WirePrevNext(pages []*engine.Page)

Types

type BuildOptions

type BuildOptions struct {
	Parallel    bool
	WorkerCount int
}

BuildOptions controls content parsing work inside collection builders.

Jump to

Keyboard shortcuts

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