entities

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	ContentPath     fields.Path           `yaml:"content_path"`
	DataPath        fields.Path           `yaml:"data_path"`
	ThemePath       fields.Path           `yaml:"theme_path"`
	HttpHost        fields.RequiredString `yaml:"http_host"`
	HttpPort        fields.HttpPort       `yaml:"http_port"`
	DefaultLangauge fields.RequiredString `yaml:"default_language"`
	BaseURL         string                `yaml:"base_url"`
}

Config represents the configuration of the site.

type Page

type Page struct {
	Parent   *Page
	Children []*Page

	Title          fields.RequiredString
	Path           *url.URL
	ContentPath    fields.Path
	Content        []byte
	PlainContent   []byte
	CreatedAt      time.Time
	LastModifiedAt *time.Time
	Words          uint
	Description    string
	Tags           []string
	Slug           string
	Aliases        []string
	Template       fields.Path
	Authors        []string
	IsDraft        bool
	Extra          map[string]any
	Language       fields.RequiredString
}

type PageCollection

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

PageCollection represents a collection of pages. The PageCollection is used to store all pages. The PageCollection is used to get a page by its URL. The PageCollection is used to get a page by its URL and language. The PageCollection is used to get all pages.

func NewPageCollection

func NewPageCollection() *PageCollection

NewPageCollection returns a new PageCollection.

func (*PageCollection) AddObserver

func (pc *PageCollection) AddObserver(observer PageCollectionObserver)

AddObserver adds an observer to the PageCollection.

func (*PageCollection) AddPage

func (pc *PageCollection) AddPage(page *Page)

AddPage adds a page to the PageCollection.

func (*PageCollection) GetPageByURL

func (pc *PageCollection) GetPageByURL(url url.URL) *Page

GetPageByURL returns a page by its URL.

func (*PageCollection) GetPageByURLAndLanguage

func (pc *PageCollection) GetPageByURLAndLanguage(url *url.URL, language fields.RequiredString) *Page

GetPageByURLAndLanguage returns a page by its URL and language.

func (*PageCollection) Pages

func (pc *PageCollection) Pages() []*Page

Pages returns all pages.

func (*PageCollection) RemoveObserver

func (pc *PageCollection) RemoveObserver(observer *PageCollectionObserver)

RemoveObserver removes an observer from the PageCollection.

func (*PageCollection) RemovePage

func (pc *PageCollection) RemovePage(page *Page)

RemovePage removes a page from the PageCollection.

func (*PageCollection) RemovePageByPath

func (pc *PageCollection) RemovePageByPath(contentPath fields.Path)

RemovePageByPath removes a page from the PageCollection by its path.

func (*PageCollection) SetDefaultLanguage

func (pc *PageCollection) SetDefaultLanguage(defaultLanguage fields.RequiredString)

SetDefaultLanguage sets the default language.

func (*PageCollection) UpdatePage

func (pc *PageCollection) UpdatePage(path fields.Path, p *Page)

UpdatePage updates a page in the PageCollection.

type PageCollectionObserver

type PageCollectionObserver interface {
	AddedPage(page *Page)
	RemovedPage(page *Page)
	UpdatedPage(page *Page)
}

PageCollectionObserver is an interface for observing changes to a PageCollection.

type Site

type Site struct {
	BaseURL  string
	Path     *url.URL
	Config   *Config
	Pages    []*Page
	Page     *Page
	Data     map[string]any
	Language fields.RequiredString
}

Site represents the site. The Site contains the current page and all pages. The Site also contains the config. The Site also contains the current path. The Site also contains the base URL. The Site also contains a map for custom data. The Site also contains the current language.

Jump to

Keyboard shortcuts

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