Documentation ¶
Index ¶
- func FileHasFrontMatter(filename string) (bool, error)
- type FrontMatter
- func (fm FrontMatter) Bool(k string, defaultValue bool) bool
- func (fm FrontMatter) Get(k string, defaultValue interface{}) interface{}
- func (fm FrontMatter) Merged(fms ...FrontMatter) FrontMatter
- func (fm FrontMatter) SortedStringArray(key string) []string
- func (fm FrontMatter) String(k string, defaultValue string) string
- func (fm FrontMatter) StringArray(k string) []string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FileHasFrontMatter ¶
FileHasFrontMatter returns a bool indicating whether the file looks like it has frontmatter.
Types ¶
type FrontMatter ¶
type FrontMatter map[string]interface{}
FrontMatter wraps a map to provide interface functions
func Merge ¶ added in v0.2.7
func Merge(fms ...FrontMatter) FrontMatter
Merge creates a new FrontMatter that merges its arguments, from first to last.
func Read ¶
func Read(sourcePtr *[]byte, firstLine *int) (fm FrontMatter, err error)
Read reads the frontmatter from a document. It modifies srcPtr to point to the content after the frontmatter, and sets firstLine to its 1-indexed line number.
func (FrontMatter) Bool ¶ added in v0.2.7
func (fm FrontMatter) Bool(k string, defaultValue bool) bool
Bool returns m[k] if it's a bool; else defaultValue.
func (FrontMatter) Get ¶ added in v0.2.7
func (fm FrontMatter) Get(k string, defaultValue interface{}) interface{}
Get returns m[k] if present; else defaultValue.
func (FrontMatter) Merged ¶ added in v0.2.7
func (fm FrontMatter) Merged(fms ...FrontMatter) FrontMatter
Merged returns a new FrontMatter.
func (FrontMatter) SortedStringArray ¶
func (fm FrontMatter) SortedStringArray(key string) []string
SortedStringArray returns a sorts list of strings from a frontmatter variable that is either a string (in which case it is a ws-separated list of words), or a list of strings.
This is the format for page categories and tags.
func (FrontMatter) String ¶ added in v0.2.7
func (fm FrontMatter) String(k string, defaultValue string) string
String returns m[k] if it's a string or can be stringified; else defaultValue.
func (FrontMatter) StringArray ¶ added in v0.2.7
func (fm FrontMatter) StringArray(k string) []string
StringArray returns m[k] if it's a []string or string array