Documentation ¶
Index ¶
- Constants
- Variables
- func BasenameWithoutExtension(path string) string
- func CopyFile(src, dst string) error
- func DirExists(path string) bool
- func FindDirsWithFiles(dir string, extensions ...string) ([]string, error)
- func FindFiles(dir string) ([]string, error)
- func FirstFileWithExtension(dir string, basename string, extensions ...string) string
- func PageListValues(pages []*Page, ctx *Page) []map[string]interface{}
- func PageValues(p *Page, ctx *Page) map[string]interface{}
- func ProcessMetadata(file string) (map[string]interface{}, error)
- func TagList(page *Page) []map[string]interface{}
- func TagSlug(name string) string
- type Checkpoint
- type Page
- type Tacker
- func (t *Tacker) Checkpoint() (*Checkpoint, error)
- func (t *Tacker) Debug(format string, args ...interface{})
- func (t *Tacker) FindTemplate(name string) (*Template, error)
- func (t *Tacker) HasChanges(prev *Checkpoint) (bool, *Checkpoint, error)
- func (t *Tacker) Log(format string, args ...interface{})
- func (t *Tacker) Reload() error
- func (t *Tacker) Tack() error
- func (t *Tacker) Tag(name string) Tag
- type Tag
- type Template
Constants ¶
const AssetDir = "public"
const ContentDir = "content"
const TargetDir = "output"
const TemplateDir = "templates"
Variables ¶
var MarkupExtensions = []string{"md", "mkd"}
var MetadataExtensions = []string{"yaml", "yml"}
var TemplateExtensions = []string{"mustache", "mu", "stache"}
Functions ¶
func FindFiles ¶
FindFiles returns a slice containing the absolute path of _all_ regular files below the given directory.
func FirstFileWithExtension ¶ added in v1.3.0
func PageListValues ¶
func PageValues ¶
func ProcessMetadata ¶
Types ¶
type Checkpoint ¶
type Checkpoint struct {
// contains filtered or unexported fields
}
Checkpoint is a full listing of all files and their respective modification timestamps of a specific directory.
func (*Checkpoint) Equals ¶
func (c *Checkpoint) Equals(o *Checkpoint) bool
Equals compares this checkpoint to another one. If an empty Checkpoint to compare with is given, or both structures do not share the exact same files, or any of the files has a different modification timestamp, they will not be regarded as “equal.”
type Page ¶
type Page struct { // available directly after construction. Slug string Name string DiskPath string Tacker *Tacker Floating bool Date time.Time // first available after call to Init() Parent *Page SiblingsAndMe []*Page Children []*Page Posts []*Page Assets map[string]struct{} Variables map[string]interface{} Template string // contains filtered or unexported fields }
Page is the main structure holding page content. Some of the fields are only available after the page has been initialized using Init().
func NewPage ¶
NewPage creates a new page structure for the specified Tacker based on the given path of the page's directory. No file i/o will take place here just yet.
func (*Page) Ancestors ¶
Ancestors returns a slice of all of this page's ancestors, starting with the immediate parent page and ending with the root page. The Page must be Init()ed prior to calling this.
func (*Page) Generate ¶
Generate renders the current page given all the content and metadata read from disk and the configured template. If not done already, calling this function will initialize the page using Init().
func (*Page) Init ¶
Init initializes the page content, by reading the content and metadata from the disk, resolving the used template and creating the necessary structures to reference other pages from this one.
func (*Page) Permalink ¶
Permalink return an absolute path to the current page based on its and it's ancestor pages' slugs. The Page must be Init()ed prior to calling this.
func (*Page) Post ¶ added in v1.3.0
Post returns `true` if the current page has a post date defined as part of the content directory name.
func (*Page) Root ¶ added in v1.1.0
Root determines if the current page is the root page of the website being tacked. The root page might be stored in the top-level content directory or a directory with the slug "index" just below the top level.
type Tacker ¶
type Tacker struct { BaseDir string Metadata map[string]interface{} Pages []*Page Posts []*Page Tags map[string][]*Page TagNames map[string]map[string]int TagIndex *Page Logger *log.Logger DebugLogger *log.Logger Strict bool }
Tacker is the main configuration structure of tack. A Tacker is used by the command-line interface, or programmatically when tacking a website from within third-party code.
func NewTacker ¶
NewTacker creates a new tack configuration structure based on the files found in the directory provided.
func (*Tacker) Checkpoint ¶
func (t *Tacker) Checkpoint() (*Checkpoint, error)
Checkpoint stats all the files within the source directory and stores the names and modification timestamps so we're able to compare this list with a future checkpoint without the need to set up file watchers.
func (*Tacker) HasChanges ¶
func (t *Tacker) HasChanges(prev *Checkpoint) (bool, *Checkpoint, error)
HasChanges will create a fresh Checkpoint for the current Tacker and compare it to the previous one. The functions returns if there are changes between the checkpoints (or none was provided in the first) place, as well the new Checkpoint, and any error which might have occurred while creating it.