entity

package
v0.6.14 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToSlug

func ToSlug(s string) string

ToSlug converts a string to a URL-safe slug. Lowercase, replace non-alphanumeric with hyphens, trim leading/trailing hyphens.

Types

type Entity

type Entity struct {
	Slug       string
	SourceFile string
	Fields     map[string]interface{}
	Sections   map[string]interface{} // section name -> content ([]string for lists, []FAQ for faqs, string for markdown)
	Body       string                 // raw markdown body (minus frontmatter)
}

Entity is a generic content item with map-based fields and parsed body sections.

func (*Entity) GetBool

func (e *Entity) GetBool(key string) bool

GetBool returns a bool field value, or false if not found/wrong type.

func (*Entity) GetFAQs

func (e *Entity) GetFAQs() []FAQ

GetFAQs returns the FAQs section as []FAQ.

func (*Entity) GetFloat

func (e *Entity) GetFloat(key string) float64

GetFloat returns a float64 field value, or 0 if not found/wrong type.

func (*Entity) GetIngredients

func (e *Entity) GetIngredients() []string

GetIngredients returns the ingredients section as []string.

func (*Entity) GetInstructions

func (e *Entity) GetInstructions() []string

GetInstructions returns the instructions section as []string.

func (*Entity) GetInt

func (e *Entity) GetInt(key string) int

GetInt returns an int field value, or 0 if not found/wrong type.

func (*Entity) GetString

func (e *Entity) GetString(key string) string

GetString returns a string field value, or empty string if not found/not a string.

func (*Entity) GetStringSlice

func (e *Entity) GetStringSlice(key string) []string

GetStringSlice returns a []string field value, or nil if not found/wrong type.

func (*Entity) HasField

func (e *Entity) HasField(key string) bool

HasField checks if a field exists and is non-empty.

type FAQ

type FAQ struct {
	Question string
	Answer   string
}

FAQ represents a question-answer pair extracted from a body section.

Jump to

Keyboard shortcuts

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