builder

package
v0.0.0-...-ace3778 Latest Latest
Warning

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

Go to latest
Published: May 8, 2022 License: MIT Imports: 22 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func After

func After(fn Handler)

After add handler after building

func AssembleSource

func AssembleSource(ctx *Context)

AssembleSource assemble some extra data in Source, such as page nodes, i18n status. it need be used after posts and pages are loaded

func Before

func Before(fn Handler)

Before add handler before building

func Build

func Build(ctx *Context)

Build do a process with Context. the context should be prepared before building.

func Compile

func Compile(ctx *Context)

Compile compile source to static files

func Counter

func Counter() int

Counter return the times of building process ran

func Read

func Read(ctx *Context)

Read do a process to read Source with Context. It does not build any thing, just read source data.

func ReadLang

func ReadLang(srcDir string) map[string]*helper.I18n

ReadLang read languages in srcDir

func ReadPages

func ReadPages(ctx *Context) ([]*model.Page, error)

ReadPages read pages files in srcDir/page

func ReadPosts

func ReadPosts(ctx *Context) ([]*model.Post, error)

ReadPosts read posts files in srcDir/post

func ReadSecondMeta

func ReadSecondMeta(srcDir string) (*model.MetaAll, error)

ReadSecondMeta read meta file in srcDir

func ReadSource

func ReadSource(ctx *Context)

ReadSource read source with *Context. parse *Context.From and read data to *Context.Source

func ReadTheme

func ReadTheme(ctx *Context)

ReadTheme read *Theme to *Context

func Sync

func Sync(ctx *Context)

Sync copy assets to destination directory

func Watch

func Watch(ctx *Context)

Watch watch changes

Types

type Builder

type Builder struct {
	IsBuilding bool
	IsWatching bool
	Counter    int
	// contains filtered or unexported fields
}

Builder is object of Builder handlers

type Context

type Context struct {

	// From is source origin
	From string
	// To is destination
	To string
	// Theme is theme origin
	ThemeName string
	// Err is error when context using
	Err error
	// Source is sources data
	Source *Source
	// Theme is theme object, use to render templates
	Theme *theme.Theme
	// Tree is url tree nodes by this context
	Tree *model.Tree
	// Sync is file syncer
	Sync *sync.Syncer
	// contains filtered or unexported fields
}

Context obtain context in once building process

func NewContext

func NewContext(cli *cli.Context, from, to, theme string) *Context

NewContext create new Context with from,to and theme args

func (*Context) Again

func (ctx *Context) Again()

Again reset some fields in context to rebuild

func (*Context) Cli

func (ctx *Context) Cli() *cli.Context

Cli get command line context in this building context

func (*Context) DstDir

func (ctx *Context) DstDir() string

DstDir get destination directory after build once

func (*Context) Duration

func (ctx *Context) Duration() float64

Duration return seconds after *Context created

func (*Context) IsValid

func (ctx *Context) IsValid() bool

IsValid check context requirement, there must have values in some fields

func (*Context) SrcDir

func (ctx *Context) SrcDir() string

SrcDir get src dir

func (*Context) SrcLangDir

func (ctx *Context) SrcLangDir() string

SrcLangDir get language dir in src

func (*Context) SrcMediaDir

func (ctx *Context) SrcMediaDir() string

SrcMediaDir get media dir in src

func (*Context) SrcPageDir

func (ctx *Context) SrcPageDir() string

SrcPageDir get page dir in src

func (*Context) SrcPostDir

func (ctx *Context) SrcPostDir() string

SrcPostDir get post dir in src

func (*Context) View

func (ctx *Context) View() map[string]interface{}

View get view data to template from Context

type Handler

type Handler func(ctx *Context)

Handler define a step in building process

type Source

type Source struct {
	Meta      *model.Meta
	Nav       model.NavGroup
	Owner     *model.Author
	Authors   map[string]*model.Author
	Comment   *model.Comment
	Analytics *model.Analytics
	Build     *model.Build
	I18n      map[string]*helper.I18n

	Posts      model.Posts
	PagePosts  map[int]*model.PagerPosts
	IndexPosts model.PagerPosts // same to PagePosts[1]
	PostPage   int
	Archive    model.Archives
	Pages      model.Pages
	Tags       map[string]*model.Tag
	TagPosts   map[string]*model.TagPosts
}

Source include all sources data

func NewSource

func NewSource(all *model.MetaAll) *Source

NewSource return new *Source from *MetaAll, it returns general *Source object without posts and pages, but meta, navigation, authors,comment and analytics are loaded.

Jump to

Keyboard shortcuts

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