Documentation
¶
Index ¶
- Variables
- func CreateGoldmark(opts MarkdownOptions, extraParserOpts ...parser.Option) goldmark.Markdown
- func ParseFrontMatter(raw []byte) (map[string]interface{}, []byte, error)
- func RenderText(source []byte) ([]byte, error)
- func SplitAtDelimiter(raw []byte, delim string) (before, after []byte, found bool)
- type HookRenderer
- type MarkdownOptions
- type Page
- func BuildPage(relPath string, raw []byte) (*Page, error)
- func Discover(contentDir string) ([]*Page, error)
- func DiscoverWithFormats(contentDir string, formats []string) ([]*Page, error)
- func DiscoverWithPassthrough(contentDir string, formats []string) ([]*Page, []string, error)
- func FilterByLifecycle(pages []*Page, now time.Time, includeDrafts bool) []*Page
- type PaginationFrontMatter
- type TOCEntry
- type TemplateTagBlock
- type TemplateTagInline
Constants ¶
This section is empty.
Variables ¶
var KindTemplateTagBlock = ast.NewNodeKind("TemplateTagBlock")
var KindTemplateTagInline = ast.NewNodeKind("TemplateTagInline")
Functions ¶
func CreateGoldmark ¶
func CreateGoldmark(opts MarkdownOptions, extraParserOpts ...parser.Option) goldmark.Markdown
CreateGoldmark builds a configured goldmark instance from options. When TemplateTags is true, template tags are preserved verbatim in the output. When false, they are escaped with zero-width spaces so the template engine won't recognize them.
func ParseFrontMatter ¶
ParseFrontMatter extracts front matter and body from raw content. Detects YAML (---), TOML (+++), or JSON ({) delimiters.
func RenderText ¶
RenderText wraps plain text content in <pre> tags for .txt files.
Types ¶
type HookRenderer ¶
HookRenderer renders a hook template with the given context variables. source is the template source and ctx contains the template variables (e.g. {"markup": {...}}).
type MarkdownOptions ¶
type MarkdownOptions struct {
Unsafe bool
Typographer bool
TemplateTags bool
AutoHeadingID bool
CustomElements bool
Hooks map[string]string
HookRenderer HookRenderer
}
MarkdownOptions controls goldmark rendering behavior.
type Page ¶
type Page struct {
SourcePath string
RelPath string
Content []byte
FrontMatter map[string]interface{}
Body []byte
RenderedBody []byte
OutputPath string
URL string
Date time.Time
Draft bool
PublishDate *time.Time
ExpiryDate *time.Time
Summary string
Layout string
Outputs []string
FormatBodies map[string][]byte // alternate format rendered bodies (e.g., "json" → rendered JSON)
Aliases []string
Permalink string
Slug string
Section string
Kind string // "page", "taxonomy", "taxonomy_term", "home", "section"
Collection string
Translations []*Page
Pagination *PaginationFrontMatter
Bundle bool
BundleAssets []string
TOC []TOCEntry
Dependencies []string // nil = untracked (always re-render); non-nil = tracked source file deps
// contains filtered or unexported fields
}
Page represents a single content file with its metadata and rendered output.
func DiscoverWithFormats ¶
DiscoverWithFormats walks the content directory and returns only pages whose file extension matches one of the allowed formats.
func DiscoverWithPassthrough ¶
DiscoverWithPassthrough walks the content directory and returns content pages (files matching formats) and passthrough file paths (everything else). Excludes _data.yaml, _data.yml, and dot-prefixed files from passthrough.
func FilterByLifecycle ¶
FilterByLifecycle removes draft, future, and expired pages based on the current time. In dev mode (includeDrafts=true), drafts are kept and draft pages bypass date constraints. publishDate and expiryDate filtering applies in both build and serve modes.
func (*Page) HTML ¶
HTML returns the string conversion of RenderedBody, caching the result so subsequent calls avoid redundant []byte→string allocations.
func (*Page) ReleaseRenderedBody ¶ added in v0.6.0
func (p *Page) ReleaseRenderedBody()
ReleaseRenderedBody frees all rendered output data to reduce peak memory. Nils RenderedBody, clears the cached HTML string, and nils FormatBodies. Safe to call multiple times and on pages with nil fields (issue #1107).
func (*Page) SetRenderedBody ¶
SetRenderedBody updates RenderedBody and clears the cached HTML string.
func (*Page) SetRenderedHTML ¶ added in v0.6.0
SetRenderedHTML stores both RenderedBody (as []byte) and the cached HTML string simultaneously, avoiding the string→[]byte→string round-trip that SetRenderedBody([]byte(html)) triggers. The pipeline uses this when applying hook results back, where the source is already a Go string from QuickJS GetPropertyStr().String() (issue #1185).
func (*Page) ToTemplateMap ¶
ToTemplateMap converts a Page to a map with lowercase keys for reliable Liquid template access. Struct fields (URL, Date, etc.) are merged on top of FrontMatter so templates can use {{ page.title }}, {{ page.url }}, etc.
type PaginationFrontMatter ¶
type PaginationFrontMatter struct {
Data string `yaml:"data" json:"data"`
PerPage int `yaml:"perPage" json:"perPage"`
As string `yaml:"as" json:"as"`
}
PaginationFrontMatter holds pagination settings from front matter.
type TOCEntry ¶
type TOCEntry struct {
ID string `json:"id"`
Text string `json:"text"`
Level int `json:"level"`
Children []TOCEntry `json:"children,omitempty"`
}
TOCEntry represents a heading in the table of contents.
func RenderMarkdown ¶
RenderMarkdown converts Markdown source to HTML and extracts a table of contents using a pre-created goldmark instance. Use this when rendering multiple pages with the same options to avoid re-creating the instance per page. The goldmark instance must have AutoHeadingID enabled for TOC IDs.
type TemplateTagBlock ¶
func (*TemplateTagBlock) Dump ¶
func (n *TemplateTagBlock) Dump(source []byte, level int)
func (*TemplateTagBlock) IsRaw ¶
func (n *TemplateTagBlock) IsRaw() bool
func (*TemplateTagBlock) Kind ¶
func (n *TemplateTagBlock) Kind() ast.NodeKind
type TemplateTagInline ¶
type TemplateTagInline struct {
ast.BaseInline
TagText []byte
}
func (*TemplateTagInline) Dump ¶
func (n *TemplateTagInline) Dump(source []byte, level int)
func (*TemplateTagInline) IsRaw ¶
func (n *TemplateTagInline) IsRaw() bool
func (*TemplateTagInline) Kind ¶
func (n *TemplateTagInline) Kind() ast.NodeKind