render

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildFuncMap

func BuildFuncMap() template.FuncMap

BuildFuncMap creates the template FuncMap with all helper functions.

func GenerateAllEntitiesShareSVG

func GenerateAllEntitiesShareSVG(siteName string, totalCount int, typeDist []NameCount) string

GenerateAllEntitiesShareSVG generates the all-entities share image SVG.

func GenerateCookModePrompt

func GenerateCookModePrompt(e *entity.Entity, enrichment map[string]interface{}, affiliateLinks []affiliate.Link) string

GenerateCookModePrompt builds a cook-with-AI prompt for a recipe.

func GenerateEntityShareSVG

func GenerateEntityShareSVG(siteName, title, category, cuisine, skillLevel string) string

GenerateEntityShareSVG generates the entity share image SVG.

func GenerateHomepageShareSVG

func GenerateHomepageShareSVG(siteName, description string, taxStats []NameCount, totalEntities int) string

GenerateHomepageShareSVG generates the homepage share image SVG.

func GenerateHubShareSVG

func GenerateHubShareSVG(siteName, entryName, taxLabel string, count int, topTypes []NameCount) string

GenerateHubShareSVG generates the hub page share image SVG.

func GenerateLetterShareSVG

func GenerateLetterShareSVG(siteName, taxLabel, letter string, entryCount int) string

GenerateLetterShareSVG generates the letter page share image SVG.

func GenerateTaxIndexShareSVG

func GenerateTaxIndexShareSVG(siteName, taxLabel string, topEntries []NameCount) string

GenerateTaxIndexShareSVG generates the taxonomy index share image SVG.

Types

type AllEntitiesPageContext

type AllEntitiesPageContext struct {
	Site          config.SiteConfig
	Entities      []*entity.Entity
	Pagination    taxonomy.PaginationInfo
	JsonLD        template.HTML
	Breadcrumbs   []Breadcrumb
	AllTaxonomies []taxonomy.Taxonomy
	EntityCount   int
	TotalEntities int
	OG            OGMeta
	ChartData     template.JS
	CTA           config.CTAConfig
}

AllEntitiesPageContext is the template context for the all-entities listing pages.

type Breadcrumb struct {
	Name string
	URL  string
}

Breadcrumb is a single breadcrumb entry.

type Engine

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

Engine is the template rendering engine.

func NewEngine

func NewEngine(cfg *config.Config) (*Engine, error)

NewEngine creates a render engine loading templates from the given directory.

func (*Engine) RenderAllEntities

func (e *Engine) RenderAllEntities(ctx AllEntitiesPageContext) (string, error)

RenderAllEntities renders an all-entities listing page.

func (*Engine) RenderCSS

func (e *Engine) RenderCSS() (string, error)

RenderCSS reads and returns the CSS template content. Uses Tree.Root.String() to avoid html/template escaping in CSS code.

func (*Engine) RenderEntity

func (e *Engine) RenderEntity(ctx EntityPageContext) (string, error)

RenderEntity renders an entity page.

func (*Engine) RenderHomepage

func (e *Engine) RenderHomepage(ctx HomepageContext) (string, error)

RenderHomepage renders the homepage.

func (*Engine) RenderHub

func (e *Engine) RenderHub(ctx HubPageContext) (string, error)

RenderHub renders a taxonomy hub page.

func (*Engine) RenderJS

func (e *Engine) RenderJS() (string, error)

RenderJS reads and returns the JS template content. Uses Tree.Root.String() to avoid html/template escaping < to &lt; in JS code.

func (*Engine) RenderLetter

func (e *Engine) RenderLetter(ctx LetterPageContext) (string, error)

RenderLetter renders a letter page.

func (*Engine) RenderStatic

func (e *Engine) RenderStatic(templateName string, ctx StaticPageContext) (string, error)

RenderStatic renders a static page.

func (*Engine) RenderTaxonomyIndex

func (e *Engine) RenderTaxonomyIndex(ctx TaxonomyIndexContext) (string, error)

RenderTaxonomyIndex renders a taxonomy index page.

type EntityPageContext

type EntityPageContext struct {
	Site           config.SiteConfig
	Entity         *entity.Entity
	Slug           string
	URL            string
	CanonicalURL   string
	Breadcrumbs    []Breadcrumb
	Pairings       []*entity.Entity
	Enrichment     map[string]interface{}
	AffiliateLinks []affiliate.Link
	CookModePrompt string
	JsonLD         template.HTML
	Taxonomies     []taxonomy.Taxonomy
	AllTaxonomies  []taxonomy.Taxonomy
	ValidSlugs     map[string]map[string]bool
	Contributors   map[string]interface{}
	OG             OGMeta
	ChartData      template.JS
	CTA            config.CTAConfig
	SourceCode     string
	SourceLang     string
}

EntityPageContext is the template context for entity (recipe) pages.

type HomepageContext

type HomepageContext struct {
	Site         config.SiteConfig
	Entities     []*entity.Entity
	Taxonomies   []taxonomy.Taxonomy
	Favorites    []*entity.Entity
	JsonLD       template.HTML
	EntityCount  int
	Contributors map[string]interface{}
	OG           OGMeta
	ChartData    template.JS
	CTA          config.CTAConfig
	ArchData     template.JS
}

HomepageContext is the template context for the homepage.

type HubPageContext

type HubPageContext struct {
	Site               config.SiteConfig
	Taxonomy           taxonomy.Taxonomy
	Entry              taxonomy.Entry
	Entities           []*entity.Entity
	Pagination         taxonomy.PaginationInfo
	JsonLD             template.HTML
	Breadcrumbs        []Breadcrumb
	AllTaxonomies      []taxonomy.Taxonomy
	Contributors       map[string]interface{}
	ContributorProfile map[string]interface{}
	OG                 OGMeta
	ChartData          template.JS
	CTA                config.CTAConfig
}

HubPageContext is the template context for taxonomy hub (category) pages.

type LetterPageContext

type LetterPageContext struct {
	Site          config.SiteConfig
	Taxonomy      taxonomy.Taxonomy
	Letter        string
	Entries       []taxonomy.Entry
	Letters       []string
	JsonLD        template.HTML
	Breadcrumbs   []Breadcrumb
	AllTaxonomies []taxonomy.Taxonomy
	OG            OGMeta
	ChartData     template.JS
	CTA           config.CTAConfig
}

LetterPageContext is the template context for A-Z letter pages.

type NameCount

type NameCount struct {
	Name  string `json:"name"`
	Count int    `json:"count"`
}

NameCount is a generic name+count pair used for chart data and share images.

type OGMeta

type OGMeta struct {
	Title       string
	Description string
	URL         string
	ImageURL    string
	Type        string // "website" for homepage, "article" for all others
	SiteName    string
}

OGMeta holds Open Graph and Twitter Card metadata for a page.

type StaticPageContext

type StaticPageContext struct {
	Site          config.SiteConfig
	Title         string
	Content       template.HTML
	JsonLD        template.HTML
	Breadcrumbs   []Breadcrumb
	AllTaxonomies []taxonomy.Taxonomy
}

StaticPageContext is the template context for static pages.

type TaxonomyIndexContext

type TaxonomyIndexContext struct {
	Site          config.SiteConfig
	Taxonomy      taxonomy.Taxonomy
	Entries       []taxonomy.Entry
	TopEntries    []taxonomy.Entry
	LetterGroups  []taxonomy.LetterGroup
	HasLetters    bool
	Letters       []string
	JsonLD        template.HTML
	Breadcrumbs   []Breadcrumb
	AllTaxonomies []taxonomy.Taxonomy
	OG            OGMeta
	ChartData     template.JS
	CTA           config.CTAConfig
}

TaxonomyIndexContext is the template context for taxonomy index pages.

Jump to

Keyboard shortcuts

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