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