Documentation
¶
Index ¶
- func DeepMerge(base, overlay map[string]interface{}) map[string]interface{}
- func FindCascadeData(cascadeData map[string]map[string]interface{}, contentBase, relPath string) map[string]interface{}
- func LoadDirectoryCascade(contentDir string) (map[string]map[string]interface{}, error)
- type PageContext
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeepMerge ¶
DeepMerge merges overlay into base following Alloy's rules: - Objects are deep-merged (nested keys merge recursively) - Arrays are replaced (not concatenated)
func FindCascadeData ¶
func FindCascadeData(cascadeData map[string]map[string]interface{}, contentBase, relPath string) map[string]interface{}
FindCascadeData walks up the directory tree from a page's directory to find the nearest ancestor with cascade data. Returns nil when no ancestor has data. LoadDirectoryCascade already accumulates ancestor data into each directory entry, so returning the nearest match is sufficient.
func LoadDirectoryCascade ¶
LoadDirectoryCascade loads and merges _data.yaml files from root through nested directories, producing the cumulative data at each level. Returns a map of directory path -> merged data at that level.
Uses a two-pass approach: first collects raw _data.yaml contents, then accumulates in depth order so that (a) parent data is always available before children regardless of WalkDir ordering, and (b) gaps in the _data.yaml chain are bridged by walking up to the nearest ancestor.
Types ¶
type PageContext ¶
type PageContext struct {
Global *map[string]interface{}
Directory *map[string]interface{}
FrontMatter map[string]interface{}
}
PageContext provides layered data lookup for a single page. Global and directory data are shared by pointer across pages.
func BuildContext ¶
func BuildContext(global, directory, frontMatter map[string]interface{}) *PageContext
BuildContext creates a PageContext from the cascade levels.
func (*PageContext) Get ¶
func (pc *PageContext) Get(key string) interface{}
Get looks up a key through the cascade levels. Priority order (highest first): FrontMatter > Directory > Global. When multiple levels have maps for the same key, they are deep-merged with higher priority levels winning on conflicts.
func (*PageContext) ToMap ¶
func (pc *PageContext) ToMap() map[string]interface{}
ToMap flattens all cascade levels into a single map using Get() for each key. The result reflects the full cascade priority (FrontMatter > Directory > Global) with lazy deep-merge for nested maps.