models

package
v1.5.4 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2026 License: BSD-3-Clause, BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package models defines data structures for content parsing

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Author

type Author struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
	Slug string `json:"slug"`
}

Author represents a site author

type Category

type Category struct {
	ID          int    `json:"id"`
	Count       int    `json:"count"`
	Description string `json:"description"`
	Link        string `json:"link"`
	Name        string `json:"name"`
	Slug        string `json:"slug"`
	Parent      int    `json:"parent"`
}

Category represents a content category

type FlexInt added in v1.4.5

type FlexInt int

FlexInt is an int that can be unmarshaled from either int or string JSON

func (*FlexInt) UnmarshalJSON added in v1.4.5

func (fi *FlexInt) UnmarshalJSON(data []byte) error

UnmarshalJSON implements custom unmarshaling for FlexInt

type MediaItem

type MediaItem struct {
	ID           int    `json:"id"`
	Slug         string `json:"slug"`
	Title        Title  `json:"title"`
	MediaType    string `json:"media_type"`
	MimeType     string `json:"mime_type"`
	SourceURL    string `json:"source_url"`
	MediaDetails struct {
		Width  FlexInt `json:"width"`
		Height FlexInt `json:"height"`
		File   string  `json:"file"`
	} `json:"media_details"`
}

MediaItem represents a media file

type Metadata

type Metadata struct {
	Categories []Category  `json:"categories"`
	ExportedAt string      `json:"exported_at"`
	Media      []MediaItem `json:"media"`
	Users      []Author    `json:"users"`
}

Metadata represents the full metadata.json structure

type Page

type Page struct {
	ID         int       `yaml:"id"`
	Title      string    `yaml:"title"`
	Slug       string    `yaml:"slug"`
	Date       time.Time `yaml:"date"`
	Modified   time.Time `yaml:"modified"`
	Status     string    `yaml:"status"`
	Type       string    `yaml:"type"`
	Link       string    `yaml:"link"`
	Author     int       `yaml:"author"`
	Categories []int     `yaml:"categories,omitempty"`
	Excerpt    string    `yaml:"-"`
	Content    string    `yaml:"-"`
	URLFormat  string    `yaml:"-"` // URL format: "date" or "slug" (set by generator)
}

Page represents a page or post content with frontmatter metadata

func (Page) GetCanonical

func (p Page) GetCanonical(domain string) string

GetCanonical returns the full canonical URL for this page/post

func (Page) GetOutputPath

func (p Page) GetOutputPath() string

GetOutputPath returns the filesystem path for this page/post Link field from frontmatter ALWAYS takes priority

func (Page) GetURL

func (p Page) GetURL() string

GetURL returns the URL path for this page/post Link field from frontmatter ALWAYS takes priority Posts without Link: use URLFormat ("date" or "slug") Pages without Link: use slug

func (Page) HasValidCategories

func (p Page) HasValidCategories() bool

HasValidCategories returns true if post has categories other than "Bez kategorii" (ID 1)

type SiteData

type SiteData struct {
	Domain     string
	Pages      []Page
	Posts      []Page
	Categories map[int]Category
	Media      map[int]MediaItem
	Authors    map[int]Author
}

SiteData holds all parsed content for template rendering

type Title

type Title struct {
	Rendered string `json:"rendered"`
}

Title represents rendered title

Jump to

Keyboard shortcuts

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