models

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Post

type Post struct {
	// Frontmatter fields
	Title       string    `yaml:"title"`
	Date        time.Time `yaml:"date"`
	Description string    `yaml:"description"`
	Tags        []string  `yaml:"tags"`
	Draft       bool      `yaml:"draft"`

	// Generated fields
	Slug        string        // URL-friendly identifier
	Content     string        // Rendered HTML content
	HTMLContent template.HTML // HTML content for templates (not escaped)
	RawContent  string        // Original markdown content
	SourcePath  string        // Path to source markdown file
	PublishDate time.Time     // Formatted publish date
}

Post represents a blog post with metadata and content

func (*Post) FormattedDate

func (p *Post) FormattedDate() string

FormattedDate returns the date in a human-readable format

func (*Post) GenerateSlug

func (p *Post) GenerateSlug()

GenerateSlug creates a URL-friendly slug from the title or filename

func (*Post) HasTag

func (p *Post) HasTag(tag string) bool

HasTag checks if the post has a specific tag

func (*Post) IsPublished

func (p *Post) IsPublished() bool

IsPublished returns true if the post is not a draft

func (*Post) ShortDate

func (p *Post) ShortDate() string

ShortDate returns the date in YYYY-MM-DD format

func (*Post) Validate

func (p *Post) Validate() error

Validate checks if the post has all required fields

type PostList

type PostList []*Post

PostList is a collection of posts with helper methods

func (PostList) FilterByTag

func (pl PostList) FilterByTag(tag string) PostList

FilterByTag returns posts that have the specified tag

func (PostList) FilterPublished

func (pl PostList) FilterPublished() PostList

FilterPublished returns only published (non-draft) posts

func (PostList) GetAllTags

func (pl PostList) GetAllTags() []string

GetAllTags returns a unique list of all tags across all posts

func (PostList) SortByDate

func (pl PostList) SortByDate()

SortByDate sorts posts by date (newest first)

Jump to

Keyboard shortcuts

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