Documentation
¶
Overview ¶
Package frontmatter provides Hugo-compatible YAML frontmatter parsing and generation.
Index ¶
Constants ¶
const ( SourceChatGPT = "chatgpt" SourceClaude = "claude" SourceClaudeCode = "claude-code" SourceGemini = "gemini" SourcePerplexity = "perplexity" SourceCodex = "codex" )
Source platform identifiers
Variables ¶
var ( // ErrInvalidFrontmatter indicates malformed frontmatter ErrInvalidFrontmatter = errors.New("invalid frontmatter format") )
Functions ¶
func ExtractDescription ¶
ExtractDescription extracts a description from content (first non-empty line or first N chars).
func GenerateConversationID ¶
func GenerateConversationID() string
GenerateConversationID creates a unique conversation ID.
func GeneratePath ¶
GeneratePath creates a file path for a conversation. Format: {folder}/{source}/{date}_{slug}.md
func GenerateSlug ¶
GenerateSlug creates a URL-friendly slug from a title.
Types ¶
type Frontmatter ¶
type Frontmatter struct {
// Hugo standard fields
Title string `yaml:"title"`
Date time.Time `yaml:"date"`
LastMod time.Time `yaml:"lastmod,omitempty"`
Draft bool `yaml:"draft,omitempty"`
Tags []string `yaml:"tags,omitempty"`
Categories []string `yaml:"categories,omitempty"`
Author string `yaml:"author,omitempty"`
Description string `yaml:"description,omitempty"`
Slug string `yaml:"slug,omitempty"`
Weight int `yaml:"weight,omitempty"`
Aliases []string `yaml:"aliases,omitempty"`
// ChatHub extension fields
Source string `yaml:"source"`
ConversationID string `yaml:"conversation_id,omitempty"`
Participants []string `yaml:"participants,omitempty"`
MessageCount int `yaml:"message_count,omitempty"`
Model string `yaml:"model,omitempty"`
Tokens int `yaml:"tokens,omitempty"`
}
Frontmatter represents Hugo-compatible YAML frontmatter with ChatHub extensions.
func New ¶
func New(title, source string) *Frontmatter
New creates a new Frontmatter with default values.
func Parse ¶
func Parse(content []byte) (*Frontmatter, []byte, error)
Parse extracts frontmatter from Markdown content. Returns the parsed frontmatter, the remaining content, and any error.
func (*Frontmatter) Render ¶
func (f *Frontmatter) Render() ([]byte, error)
Render generates YAML frontmatter bytes.
func (*Frontmatter) RenderWithContent ¶
func (f *Frontmatter) RenderWithContent(content []byte) ([]byte, error)
RenderWithContent generates complete Markdown with frontmatter and content.