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: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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