normalizer

package
v1.0.24 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FrontMatter

type FrontMatter struct {
	Title       string `yaml:"title,omitempty"`
	Layout      string `yaml:"layout,omitempty"`
	Parent      string `yaml:"parent,omitempty"`
	GrandParent string `yaml:"grand_parent,omitempty"`
	NavOrder    int    `yaml:"nav_order,omitempty"`
	HasChildren bool   `yaml:"has_children,omitempty"`
	Permalink   string `yaml:"permalink,omitempty"`

	// Extra holds entries this package does not model. They are carried
	// through unchanged: the site generator and its theme read keys beyond
	// the ones above, so dropping them would silently change the site.
	Extra map[string]interface{} `yaml:"-"`
}

FrontMatter represents the YAML front matter of a documentation page.

func GenerateFrontMatter

func GenerateFrontMatter(opts FrontMatterOptions) *FrontMatter

GenerateFrontMatter creates appropriate front matter based on context

func MergeFrontMatter

func MergeFrontMatter(existing, new *FrontMatter) *FrontMatter

MergeFrontMatter merges new front matter with existing, preferring existing values

func ParseFrontMatter

func ParseFrontMatter(content string) (*FrontMatter, string, error)

ParseFrontMatter extracts front matter from markdown content. Content without a recognizable block is returned unchanged with a nil front matter.

func (*FrontMatter) ToYAML

func (fm *FrontMatter) ToYAML() (string, error)

ToYAML converts front matter to YAML string with delimiters.

type FrontMatterOptions

type FrontMatterOptions struct {
	FilePath    string // Relative file path from docs root
	Language    string // Programming language (go, python, etc.)
	Section     string // Documentation section (_api, _stack, etc.)
	IsIndex     bool   // Whether this is an index.md file
	CustomTitle string // Custom title override
}

FrontMatterOptions provides context for generating front matter

type Normalizer

type Normalizer struct {
	// contains filtered or unexported fields
}

Normalizer handles adding Jekyll front matter to markdown files

func NewNormalizer

func NewNormalizer(docsRoot string) *Normalizer

NewNormalizer creates a new markdown normalizer

func (*Normalizer) NormalizeDir

func (n *Normalizer) NormalizeDir(dirPath string) (int, []error)

NormalizeDir recursively processes all markdown files in a directory

func (*Normalizer) NormalizeFile

func (n *Normalizer) NormalizeFile(filePath string) error

NormalizeFile adds or updates front matter in a single markdown file

Jump to

Keyboard shortcuts

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