renderer

package
v0.0.0-...-30b578c Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2019 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Layout

type Layout struct {
	WebsiteTitle  string
	WebsiteOwner  string
	ContentTitle  string
	ContentDesc   string
	ContentAuthor string
	Pages         []model.Page
}

Layout is the base layout of the website

type List

type List struct {
	Layout
	Type        ListType
	Path        string
	Posts       []model.Post
	Tags        []model.Group
	Categories  []model.Group
	CurrentPage int
	MaxPage     int
}

List is layout that used in list template. Might be used in frontpage template as well.

type ListType

type ListType int

ListType is the type of list that will be rendered.

const (
	// DEFAULT means the list is default that shows all posts.
	DEFAULT ListType = iota
	// CATEGORY means the list is list that only shows posts with specified category.
	CATEGORY
	// TAG means the list is list that only shows posts with specified tags.
	TAG
)

type Page

type Page struct {
	Layout
	Thumbnail string
	HTML      template.HTML
}

Page is layout that used in single page

type Post

type Post struct {
	Layout
	CreatedAt string
	UpdatedAt string
	Category  model.Group
	Tags      []model.Group
	Thumbnail string
	HTML      template.HTML
	Older     model.Post
	Newer     model.Post
}

Post is layout that used in post

type Renderer

type Renderer struct {
	Config     model.Config
	Pages      []model.Page
	Posts      []model.Post
	Tags       []model.Group
	Categories []model.Group
	Minimize   bool
	RootDir    string
}

Renderer is used to render static HTML file

func (Renderer) RenderFrontPage

func (rd Renderer) RenderFrontPage(dst io.Writer) error

RenderFrontPage renders front page of the site. If exists, it will use the front page template. If not, it will fallback to using list template.

func (Renderer) RenderList

func (rd Renderer) RenderList(listType ListType, groupName string, pageNumber int, dst io.Writer) (int, error)

RenderList renders list template.

func (Renderer) RenderPage

func (rd Renderer) RenderPage(page model.Page, dst io.Writer) error

RenderPage renders page template.

func (Renderer) RenderPost

func (rd Renderer) RenderPost(post, olderPost, newerPost model.Post, dst io.Writer) error

RenderPost renders post template.

Jump to

Keyboard shortcuts

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