markdown

package
v0.9.8 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildCollectionIndex

func BuildCollectionIndex(docs []*Document, baseURL string, limit int) map[string]interface{}

BuildCollectionIndex creates a schema.org CollectionPage index limit controls how many items to include (0 means no limit)

func BuildCollectionIndexWithMeta

func BuildCollectionIndexWithMeta(docs []*Document, baseURL string, limit int, indexDoc *Document) map[string]interface{}

BuildCollectionIndexWithMeta creates a schema.org CollectionPage index with optional metadata from index.md limit controls how many items to include (0 means no limit) indexDoc contains optional metadata like sameAs from the site's index.md

func SerializeJSONLD

func SerializeJSONLD(jsonld map[string]interface{}) ([]byte, error)

SerializeJSONLD serializes JSON-LD to formatted JSON

func SortDocumentsByDate

func SortDocumentsByDate(docs []*Document)

SortDocumentsByDate sorts documents by DatePublished descending (newest first), then by Title ascending for items with the same date

func ValidateFrontmatter

func ValidateFrontmatter(fm Frontmatter) error

ValidateFrontmatter validates frontmatter against required fields

Types

type Document

type Document struct {
	Frontmatter Frontmatter
	Content     string // Raw markdown content
	HTML        string // Rendered HTML
	FilePath    string // Path to the source file
}

Document represents a parsed markdown document

func ListDocuments

func ListDocuments(contentDir string) ([]*Document, error)

ListDocuments finds all markdown documents in a directory

func ParseDocument

func ParseDocument(filePath string) (*Document, error)

ParseDocument parses a markdown file with YAML frontmatter

func ParseDocumentFromBytes

func ParseDocumentFromBytes(content []byte, filePath string) (*Document, error)

ParseDocumentFromBytes parses markdown content with YAML frontmatter

func ParseIndexDocument

func ParseIndexDocument(filePath string) (*Document, error)

ParseIndexDocument parses an index.md file with minimal frontmatter requirements Unlike regular documents, index.md doesn't require datePublished, author, or lang

func (*Document) ToJSONLD

func (d *Document) ToJSONLD(baseURL string) map[string]interface{}

ToJSONLD converts frontmatter to schema.org JSON-LD

type Frontmatter

type Frontmatter struct {
	Title         string      `yaml:"title" json:"title"`
	Description   string      `yaml:"description,omitempty" json:"description,omitempty"`
	DatePublished string      `yaml:"datePublished,omitempty" json:"datePublished,omitempty"`
	DateModified  string      `yaml:"dateModified,omitempty" json:"dateModified,omitempty"`
	Author        interface{} `yaml:"author,omitempty" json:"author,omitempty"`
	Tags          []string    `yaml:"tags,omitempty" json:"tags,omitempty"`
	Collection    string      `yaml:"collection,omitempty" json:"collection,omitempty"`
	Lang          string      `yaml:"lang,omitempty" json:"lang,omitempty"`
	Draft         bool        `yaml:"draft,omitempty" json:"draft,omitempty"`
	Slug          string      `yaml:"slug,omitempty" json:"slug,omitempty"`
	Image         string      `yaml:"image,omitempty" json:"image,omitempty"`
	Keywords      []string    `yaml:"keywords,omitempty" json:"keywords,omitempty"`
	Icon          string      `yaml:"icon,omitempty" json:"icon,omitempty"`
	SameAs        []string    `yaml:"sameAs,omitempty" json:"sameAs,omitempty"`
}

Frontmatter represents the YAML frontmatter of a document

Jump to

Keyboard shortcuts

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