mate

package
v0.0.0-...-00775ca Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2023 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultDelimiter = "---"

DefaultDelimiter is the default delimiter that encloses the YAML preamble

Variables

This section is empty.

Functions

func ParseLayout

func ParseLayout(layoutPath string, data interface{}, project *Project) (string, error)

Types

type Aggregator

type Aggregator struct {
}

func NewAggregator

func NewAggregator() *Aggregator

func (*Aggregator) AggregatePostPaths

func (a *Aggregator) AggregatePostPaths(p *Project) ([]string, error)

AggregatePostPaths scans the posts folder recursively, gathering the markdown files, providing an array of their paths

type FrontMatter

type FrontMatter struct {
	// contains filtered or unexported fields
}

FrontMatter will help access the front matter of the posts; the front matter is a YAML preamble enclosed by delimiters (`---`) that can provide additional metadata about the post itself (f. ex. set anouther layout, provide tags, ...) as key-value pairs. It's optional but if present it must be at the beginning of the document.

func NewFrontMatterFromSource

func NewFrontMatterFromSource(src string) *FrontMatter

func (*FrontMatter) GetArrayValue

func (f *FrontMatter) GetArrayValue(key string) []string

GetArrayValue will provide the value of a frontmatter field as a string array, using comma as a separator and trimming the whitespace from each string. The default will be an empty array.

func (*FrontMatter) GetBody

func (f *FrontMatter) GetBody() string

GetBody will provide the contents of the post with front matter removed.

func (*FrontMatter) GetValue

func (f *FrontMatter) GetValue(key, defaultVal string) string

GetValue will provide the value of a frontmatter field, or a default if not found.

func (*FrontMatter) GetValues

func (f *FrontMatter) GetValues() map[string]string

type PageSorter

type PageSorter func(i, j int) bool

PageSorter ...

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

func NewParser

func NewParser() *Parser

func (*Parser) ParsePath

func (p *Parser) ParsePath(path string, project *Project) (*Post, error)

func (*Parser) ParsePaths

func (p *Parser) ParsePaths(paths []string, project *Project) ([]Post, error)

ParsePaths will scan a slice of local, relative paths (provided ideally by mate.Aggregator) performing ParsePath on each one and returning an array of pages.

type Post

type Post struct {
	CreatedOn time.Time
	Title     string
	Tags      []string
	Source    string
	Body      template.HTML
	Author    string
	Layout    string
	Path      string
	File      string
	Slug      string
	Project   *Project
}

Post is the logical representation of a post for the application.

type Project

type Project struct {
	// contains filtered or unexported fields
}

Project ...

func NewProject

func NewProject(workingDir, postsPath, layoutsPath, publicPath, tagsPath string) *Project

NewProject ...

func (*Project) AddPost

func (p *Project) AddPost(post Post)

AddPost ...

func (*Project) AddTags

func (p *Project) AddTags(tag ...string)

AddTags ...

func (*Project) CreatedOnSorter

func (p *Project) CreatedOnSorter() PageSorter

CreatedOnSorter ...

func (*Project) GetLayoutsDirectory

func (p *Project) GetLayoutsDirectory() string

GetLayoutsDirectory ...

func (*Project) GetPostsDirectory

func (p *Project) GetPostsDirectory() string

GetPostsDirectory ...

func (*Project) GetPublicDirectory

func (p *Project) GetPublicDirectory() string

GetPublicDirectory ...

func (*Project) GetPublicTagsPath

func (p *Project) GetPublicTagsPath() string

GetPublicTagsPath ...

func (*Project) GetTags

func (p *Project) GetTags() []Tag

GetTags ...

func (*Project) Posts

func (p *Project) Posts() []Post

Posts ...

func (*Project) PostsSorted

func (p *Project) PostsSorted(sortFunction PageSorter) []Post

PostsSorted ...

type Tag

type Tag struct {
	Name string
}

Tag ...

type TagList

type TagList struct {
	// contains filtered or unexported fields
}

TagList ...

func NewTagList

func NewTagList() *TagList

func (*TagList) AddTag

func (tl *TagList) AddTag(t string) *TagList

AddTag ...

func (*TagList) AddTags

func (tl *TagList) AddTags(tags []string) *TagList

AddTags ...

func (*TagList) GetTags

func (tl *TagList) GetTags() []Tag

GetTags ...

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

Writer ...

func NewWriter

func NewWriter(ps postsaver.PostSaver) *Writer

NewWriter ...

func (*Writer) Clean

func (w *Writer) Clean(project *Project) error

Clean ...

func (*Writer) Write

func (w *Writer) Write(post Post, project *Project) error

func (*Writer) WritePages

func (w *Writer) WritePages(posts []Post, project *Project) error

WritePages ...

func (*Writer) WriteTag

func (w *Writer) WriteTag(tag Tag, project *Project) error

WriteTag ...

func (*Writer) WriteTags

func (w *Writer) WriteTags(posts []Post, project *Project) error

WriteTags ...

Jump to

Keyboard shortcuts

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