content

package
v1.4.6 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyWorkflowToFrontMatter

func ApplyWorkflowToFrontMatter(fm *FrontMatter, status string, publishAt, unpublishAt *time.Time, note string)

func AuthorArchiveURL

func AuthorArchiveURL(defaultLang, lang, author string) string

AuthorArchiveURL returns the canonical built-in author archive URL for a language-aware site.

func AuthorSlug

func AuthorSlug(name string) string

AuthorSlug normalizes a human author name into the canonical segment used by Foundry's built-in author archive routes.

func BuildNewContent

func BuildNewContent(cfg *config.Config, kind, slug string) (string, error)

func BuildNewContentWithOptions

func BuildNewContentWithOptions(cfg *config.Config, opts NewContentOptions) (string, error)

func NewWatcher

func NewWatcher() (*fsnotify.Watcher, error)

func SearchPageURL

func SearchPageURL(defaultLang, lang string) string

SearchPageURL returns the canonical built-in search page URL for a language-aware site.

Types

type Document

type Document struct {
	ID         string
	Type       string
	Lang       string
	IsDefault  bool
	Status     string
	Title      string
	Slug       string
	URL        string
	Layout     string
	SourcePath string
	RelPath    string
	RawBody    string
	HTMLBody   template.HTML
	Summary    string
	Date       *time.Time
	CreatedAt  *time.Time
	UpdatedAt  *time.Time
	Draft      bool
	Author     string
	LastEditor string
	Params     map[string]any
	Fields     map[string]any
	Taxonomies map[string][]string
}

type FrontMatter

type FrontMatter struct {
	Title      string              `yaml:"title"`
	Slug       string              `yaml:"slug"`
	Layout     string              `yaml:"layout"`
	Draft      bool                `yaml:"draft"`
	Summary    string              `yaml:"summary"`
	Date       *time.Time          `yaml:"date"`
	CreatedAt  *time.Time          `yaml:"created_at,omitempty"`
	UpdatedAt  *time.Time          `yaml:"updated_at"`
	Author     string              `yaml:"author,omitempty"`
	LastEditor string              `yaml:"last_editor,omitempty"`
	Fields     map[string]any      `yaml:"fields"`
	Tags       []string            `yaml:"tags"`
	Categories []string            `yaml:"categories"`
	Taxonomies map[string][]string `yaml:"taxonomies"`
	Params     map[string]any      `yaml:",inline"`
}

func ParseDocument

func ParseDocument(src []byte) (*FrontMatter, string, error)

type Hooks

type Hooks interface {
	OnContentDiscovered(path string) error
	OnFrontmatterParsed(*Document) error
	OnMarkdownRendered(*Document) error
	OnDocumentParsed(*Document) error
	OnDataLoaded(map[string]any) error
	OnGraphBuilding(*SiteGraph) error
	OnGraphBuilt(*SiteGraph) error
	OnTaxonomyBuilt(*SiteGraph) error
}

Hooks exposes the content-loading lifecycle to plugins and other integrators.

The hook order for a full load is:

  1. OnDataLoaded
  2. OnGraphBuilding
  3. For each discovered document: a. OnContentDiscovered b. OnFrontmatterParsed c. OnMarkdownRendered d. OnDocumentParsed
  4. OnTaxonomyBuilt
  5. OnGraphBuilt

Hook implementations may mutate Document and SiteGraph values, but should do so carefully because later phases depend on normalized data.

type Loader

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

Loader reads content files and data files from disk, normalizes them into Documents, and assembles the SiteGraph used by rendering and serving.

func NewLoader

func NewLoader(cfg *config.Config, hooks Hooks, includeDrafts bool) *Loader

NewLoader constructs a loader for the current configuration.

When includeDrafts is false, draft and scheduled-unpublished documents are omitted from the resulting graph.

func (*Loader) Load

func (l *Loader) Load(ctx context.Context) (*SiteGraph, error)

Load reads content and data from disk and returns a fully assembled SiteGraph.

type NewContentOptions

type NewContentOptions struct {
	Kind      string
	Slug      string
	Archetype string
	Lang      string
}

type SiteGraph

type SiteGraph struct {
	Config     *config.Config
	Documents  []*Document
	ByURL      map[string]*Document
	ByType     map[string][]*Document
	ByLang     map[string][]*Document
	Taxonomies *taxonomy.Index
	Data       map[string]any
	Redirects  []redirects.Rule
}

func NewSiteGraph

func NewSiteGraph(cfg *config.Config) *SiteGraph

func (*SiteGraph) Add

func (g *SiteGraph) Add(doc *Document)

type Workflow

type Workflow struct {
	Status             string
	Archived           bool
	InReview           bool
	ScheduledPublish   *time.Time
	ScheduledUnpublish *time.Time
	EditorialNote      string
}

func WorkflowFromFrontMatter

func WorkflowFromFrontMatter(fm *FrontMatter, now time.Time) Workflow

Jump to

Keyboard shortcuts

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