frontmatter

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileHasFrontMatter

func FileHasFrontMatter(filename string) (bool, error)

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

Jump to

Keyboard shortcuts

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