theme

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package theme provides functions for working with verless themes.

Instead of juggling around with theme paths on your own, you should use the convenience functions from this package.

Index

Constants

View Source
const (
	TemplatesDir string = "templates"
	GeneratedDir string = "generated"
	CssDir       string = "css"
	JsDir        string = "js"
	// AssetsDir is the directory containing CSS and JavaScript files.
	// It will replace CssDir and JsDir in a future release.
	AssetsDir        string = "assets"
	Default          string = "default"
	PageTemplate     string = "page.html"
	ListPageTemplate string = "list-page.html"
)

Variables

This section is empty.

Functions

func AssetsPath added in v0.4.8

func AssetsPath(path, name string) string

AssetsPath returns the assets directory path of a given theme.

func CssPath added in v0.4.8

func CssPath(path, name string) string

CssPath returns the css directory path of a given theme.

func Exists

func Exists(path, name string) bool

Exists determines whether a theme with the provided name inside the given path exists.

func GeneratedPath added in v0.4.8

func GeneratedPath(path, name string) string

GeneratedPath returns the generated directory path of a given theme.

func GetTypes added in v0.5.0

func GetTypes(cfg *Config, defaultTypes map[string]*model.Type) map[string]*model.Type

GetTypes returns the declared page types from the given configuration. If there are no types configured, it returns the given default types.

verless 1.0.0 will remove the types key in verless.yml, which will make this function obsolete.

func JsPath added in v0.4.8

func JsPath(path, name string) string

JsPath returns the js directory path of a given theme.

func Path added in v0.4.8

func Path(path, name string) string

Path returns the directory path for the theme with the given name inside the given path. Path does not ensure that the directory physically exists.

func RunBeforeHooks

func RunBeforeHooks(path, name string, cfg *Config) error

RunBeforeHooks executes all pre-build commands specified in the given theme configuration.

Note that the command context directory is the the theme directory instead of the project directory.

func TemplatePath added in v0.4.8

func TemplatePath(path, name string) string

TemplatePath returns the template directory path of a given theme.

Types

type Config

type Config struct {
	Version string
	Types   map[string]*model.Type
	Build   struct {
		Before []string
	}
}

Config represents a theme configuration. This is the configuration stored in the theme.yml file, which currently is not mandatory.

func GetConfig

func GetConfig(path, name string) (Config, error)

GetConfig returns the configuration stored in theme.yml of the theme with the given name inside the given path. Since theme.yml isn't mandatory, GetConfig returns an empty config if it doesn't exist.

Jump to

Keyboard shortcuts

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