content

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package content provides content tree data structures and navigation for gozzi.

Package content provides related posts finding with tag-based scoring.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateSlug

func GenerateSlug(path string, parent *Node) string

GenerateSlug generates a URL-friendly slug from a file path.

func StripDatePrefixFromPath added in v0.0.38

func StripDatePrefixFromPath(path string) string

StripDatePrefixFromPath strips date prefixes from all path components

Types

type Node

type Node struct {
	Type      NodeType
	Path      string
	Slug      string
	Permalink string
	URL       string
	Config    map[string]any
	Content   template.HTML
	Summary   template.HTML
	Parent    *Node
	Children  []*Node
	Lower     *Node
	Higher    *Node
	WordCount int
	ReadTime  int
	Toc       []map[string]any
	Aliases   []string
}

Node represents a content node in the hierarchical content tree.

func NewContentNode

func NewContentNode(path string, parent *Node) *Node

NewContentNode creates a new content node with the given path and parent.

func (*Node) TemplateChain

func (node *Node) TemplateChain() []string

TemplateChain returns the hierarchical chain of template names.

func (*Node) ToMap

func (node *Node) ToMap() map[string]any

ToMap converts the node to a map for template rendering.

func (*Node) ToMapMinimal added in v0.0.32

func (node *Node) ToMapMinimal() map[string]any

ToMapMinimal returns a minimal map representation for cache efficiency.

type NodeType

type NodeType int

NodeType represents the type of content node (section or page).

const (
	// NodeTypeSection represents a content section (directory).
	NodeTypeSection NodeType = iota
	// NodeTypePage represents a content page (markdown file).
	NodeTypePage
)

type RelatedPostsConfig added in v0.0.26

type RelatedPostsConfig struct {
	// MaxCandidates is how many top candidates to find before randomization (default: 10)
	MaxCandidates int
	// ResultLimit is how many posts to return (default: 6)
	ResultLimit int
	// TagMatchWeight is score points per matching tag (default: 10)
	TagMatchWeight int
	// RecencyDecayDays is how many days reduce score by 1 point (default: 30)
	RecencyDecayDays int
	// RandomBonusMax is maximum random bonus points for variety (default: 2)
	RandomBonusMax int
	// MinTagMatches is minimum tag overlap required (default: 1)
	MinTagMatches int
}

RelatedPostsConfig controls related posts algorithm behavior.

func DefaultRelatedConfig added in v0.0.26

func DefaultRelatedConfig() RelatedPostsConfig

DefaultRelatedConfig returns sensible defaults for related posts.

type RelatedPostsFinder added in v0.0.26

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

RelatedPostsFinder finds related posts using tag-based scoring.

func NewRelatedPostsFinder added in v0.0.26

func NewRelatedPostsFinder(posts []*Node, config RelatedPostsConfig) *RelatedPostsFinder

NewRelatedPostsFinder creates a finder with tag index.

func (*RelatedPostsFinder) FindRelated added in v0.0.26

func (rf *RelatedPostsFinder) FindRelated(currentPage *Node) []*Node

FindRelated returns related posts for the given page, with randomization for variety.

Jump to

Keyboard shortcuts

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