frontmatter.go (view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
package main import ( "bytes" "github.com/adrg/frontmatter" ) type Matter struct { Template string `yaml:"template"` URL string `yaml:"url"` Title string `yaml:"title"` Subtitle string `yaml:"subtitle"` Date string `yaml:"date"` Body string } // Parses frontmatter, populates the `matter` struct and // returns the rest func parseFrontmatter(inputBytes []byte) ([]byte, Matter) { m := Matter{} input := bytes.NewReader(inputBytes) rest, err := frontmatter.Parse(input, &m) if err != nil { printErr(err) } return rest, m } |