load

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package load assembles a site's `.norcube/cms/` directory (or the legacy single `norcube-cms.config.yml`) into one merged document, the same way the CMS service does: `config.yml` supplies the root keys, each file under `collections/`, `blocks/` and `inputs/` becomes one entry keyed by its basename, `inputsFromGlob` adds more inputs, every `$ref` is replaced by the block or input it names, and the schema version is checked.

Unlike the service, which skips a file it cannot parse with a log line, Load reports every such problem as a finding and keeps going, so a site author sees all of them at once.

Index

Constants

View Source
const (
	ConfigDir        = ".norcube/cms"
	ConfigFile       = ConfigDir + "/config.yml"
	CollectionsDir   = ConfigDir + "/collections"
	BlocksDir        = ConfigDir + "/blocks"
	InputsDir        = ConfigDir + "/inputs"
	LegacyConfigFile = "norcube-cms.config.yml"
)

Paths inside a site.

Variables

View Source
var ErrNotASite = errors.New("no .norcube/cms/config.yml and no norcube-cms.config.yml")

ErrNotASite is returned when neither the directory layout nor the legacy file exists.

Functions

func BlockFile

func BlockFile(key string) string

func CollectionFile

func CollectionFile(key string) string

CollectionFile, BlockFile and InputFile name the file a schema entry lives in under the directory layout.

func FileFor

func FileFor(kind, key string) string

FileFor returns the schema file that defines a collection, block or input, for findings that point at one.

func InputFile

func InputFile(key string) string

Types

type Document

type Document struct {
	// Root is the merged mapping after `$ref` resolution, with every
	// key in source order.
	Root *yaml.Node
	// Merged is Root as plain values.
	Merged map[string]any
	// Config is the typed view of Merged.
	Config *schema.Config
	// Files lists the schema files that were read, in load order.
	Files []string
	// Legacy is true when the single-file layout was used.
	Legacy bool
}

Document is the loaded configuration.

func Load

func Load(fsys fs.FS) (*Document, []report.Finding, error)

Load reads the site rooted at fsys. Problems in individual files are returned as findings; the error is reserved for I/O failures and for ErrNotASite.

Jump to

Keyboard shortcuts

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