Documentation
¶
Overview ¶
Package build provides verless' core build functionality.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Run ¶
Run executes the build using the provided build context.
The current build implementation runs the following steps to build the static site:
- Read all Markdown files and send them through a channel.
- Spawn n workers reading from the channel, where n = `parallelism`.
- Build the pages concurrently: 3.1. Read the file as a []byte 3.2. Parse the file and convert it to a model.Page. 3.3. Register the page in the builder's site model. 3.4. Let each plugin process the page.
- Get the finished site model with all pages from the builder.
- Render that site model as HTML.
- Let each plugin finish its work, e.g. by writing a file.
For further info on one of these steps, see its implementation.
If any error occurs it is returned as a slice of errors as there can be several errors from the concurrent goroutines at the same time. If any error occurs all goroutines are stopped as soon as possible.
Types ¶
type Builder ¶
type Builder interface {
// RegisterPage must be safe for concurrent usage.
RegisterPage(page model.Page) error
Dispatch() (model.Site, error)
}
Builder represents a model builder that maintains a Site instance and registers all parsed pages in that instance.
type Context ¶
type Context struct {
Path string
Parser Parser
Builder Builder
Writer Writer
Plugins []Plugin
Types map[string]*model.Type
}
Context provides all components required for running a build.
type Parser ¶
type Parser interface {
// ParsePage must be safe for concurrent usage.
ParsePage(src []byte) (model.Page, error)
}
Parser represents a parser that processes Markdown files and converts them into a model instance.
type Plugin ¶
type Plugin interface {
// ProcessPage will be invoked after parsing the page.
// Must be safe for concurrent usage.
ProcessPage(page *model.Page) error
// PreWrite will be invoked before writing the site.
PreWrite(site *model.Site) error
// PostWrite will be invoked after writing the site.
PostWrite() error
}
Plugin represents a built-in verless plugin.