content

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache wraps Ristretto cache for blog posts

func NewCache

func NewCache(maxSizeMB int64, ttl time.Duration) (*Cache, error)

NewCache creates a new cache instance

func (*Cache) Clear

func (c *Cache) Clear()

Clear clears all cached posts

func (*Cache) Close

func (c *Cache) Close()

Close closes the cache

func (*Cache) Get

func (c *Cache) Get(slug string) *models.Post

Get retrieves a post from cache by slug

func (*Cache) Set

func (c *Cache) Set(slug string, post *models.Post)

Set stores a post in cache

func (*Cache) Stats

func (c *Cache) Stats() *CacheStats

Stats returns cache statistics

type CacheStats

type CacheStats struct {
	Hits      uint64
	Misses    uint64
	KeysAdded uint64
	HitRatio  float64
}

CacheStats represents cache statistics

type Loader

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

Loader handles loading and managing blog posts

func NewLoader

func NewLoader(contentPath string, cache *Cache) (*Loader, error)

NewLoader creates a new content loader

func (*Loader) GetAll

func (l *Loader) GetAll() []*models.Post

GetAll returns all published posts

func (*Loader) GetAllTags

func (l *Loader) GetAllTags() []string

GetAllTags returns all unique tags from all posts

func (*Loader) GetBySlug

func (l *Loader) GetBySlug(slug string) (*models.Post, error)

GetBySlug retrieves a post by its slug

func (*Loader) GetByTag

func (l *Loader) GetByTag(tag string) []*models.Post

GetByTag returns all posts with a specific tag

func (*Loader) GetPaginated

func (l *Loader) GetPaginated(page, perPage int) ([]*models.Post, int, error)

GetPaginated returns a paginated slice of posts

func (*Loader) LoadAll

func (l *Loader) LoadAll() error

LoadAll loads all markdown posts from the content directory

func (*Loader) Reload

func (l *Loader) Reload() error

Reload reloads all posts from disk

func (*Loader) Search

func (l *Loader) Search(query string) []*models.Post

Search performs a simple search across post titles, descriptions, and content

func (*Loader) SetReloadCallback added in v0.5.0

func (l *Loader) SetReloadCallback(callback func(int))

SetReloadCallback sets the callback to be called when content is reloaded

func (*Loader) StopWatching added in v0.5.0

func (l *Loader) StopWatching() error

StopWatching stops the file watcher

func (*Loader) Watch

func (l *Loader) Watch() error

Watch starts watching the content directory for changes

Jump to

Keyboard shortcuts

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