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 ¶
GenerateSlug generates a URL-friendly slug from a file path.
func StripDatePrefixFromPath ¶ added in v0.0.38
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 ¶
NewContentNode creates a new content node with the given path and parent.
func (*Node) TemplateChain ¶
TemplateChain returns the hierarchical chain of template names.
func (*Node) ToMapMinimal ¶ added in v0.0.32
ToMapMinimal returns a minimal map representation for cache efficiency.
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.