model

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package model provides the verless domain entities.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMessageAnyRouteError = "route '%v': %w"

	ErrWrongRouteFormat      = errors.New("the route has an invalid format")
	ErrChildNodeDoesNotExist = errors.New("child node does not exist")
)

Functions

This section is empty.

Types

type Footer struct {
	Items []FooterItem
}

Footer represents the website's footer.

type FooterItem

type FooterItem struct {
	Label  string
	Target string
}

FooterItem represents an item in the footer.

type IndexPage

type IndexPage struct {
	Page
	Pages []*Page
}

IndexPage represents an overview page that is generated for each content sub-directory.

type Meta

type Meta struct {
	Title       string
	Subtitle    string
	Description string
	Author      string
	Base        string
}

Meta represents global metadata for the website.

type Nav struct {
	Items []NavItem
}

Nav represents the website's navigation.

type NavItem struct {
	Label  string
	Target string
}

NavItem represents an item in the navigation.

type Node added in v0.1.7

type Node struct {
	Children  map[string]*Node
	Pages     []Page
	IndexPage IndexPage
}

Node represents an URL like /blog that contains multiple pages, an overview page (IndexPage) and child routes.

type Page

type Page struct {
	Route       string
	ID          string
	Title       string
	Author      string
	Date        time.Time
	Tags        []string
	Img         string
	Credit      string
	Description string
	Content     string
	Related     []*Page
	Type        *Type
	Template    string
	// contains filtered or unexported fields
}

Page represents a sub-page of the website.

func (*Page) AddProvidedRelated added in v0.2.0

func (p *Page) AddProvidedRelated(relatedFQN string)

AddProvidedRelated adds a new Fully Qualified Name URI to the page.

func (*Page) Hidden

func (p *Page) Hidden() bool

Hidden describes if the page should be shown (false) or hidden (true).

func (*Page) ProvidedRelated added in v0.2.0

func (p *Page) ProvidedRelated() []string

ProvidedRelated returns all Fully Qualified Name URIs related to the page.

func (*Page) ProvidedType added in v0.2.0

func (p *Page) ProvidedType() string

ProvidedType returns the user-provided page type.

func (*Page) SetHidden

func (p *Page) SetHidden(hidden bool)

SetHidden shows (false) or hides (true) the page.

func (*Page) SetProvidedType added in v0.2.0

func (p *Page) SetProvidedType(providedType string)

SetProvidedType sets the user-provided page type.

type Site

type Site struct {
	Meta   Meta
	Nav    Nav
	Root   Node
	Footer Footer
}

Site represents the actual website. The site model is generated and populated with data and content during the website build.

Any build.Writer implementation is capable of rendering this model as a static website.

func (*Site) CreateNode added in v0.1.7

func (s *Site) CreateNode(route string) (*Node, error)

CreateNode creates a new node in the route tree. The route has to start with a slash representing the root route, e. g. /blog. Returns the error ErrMessageWrongRouteFormat if the given route has a invalid format. This is the case when the route does not start with a '/'.

func (*Site) ResolveNode added in v0.1.7

func (s *Site) ResolveNode(route string) (*Node, error)

ResolveNode resolves and returns a route in the route tree. Has to start with a slash representing the root route. Returns the error ErrMessageWrongRouteFormat if the given route has a invalid format. This is the case when the route does not start with a '/'.

func (*Site) WalkTree added in v0.1.7

func (s *Site) WalkTree(walkFn walkFn, maxDepth int) error

WalkTree traverses the site's route tree and invokes the given walkFn on each node. Use maxDepth = -1 to traverse all nodes.

type Type added in v0.2.0

type Type struct {
	Template string
}

Type represents a page type.

Jump to

Keyboard shortcuts

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