markdown/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 |
package markdown import ( "bytes" "github.com/adrg/frontmatter" ) type Matter map[string]string type MarkdownDoc struct { Frontmatter Matter Body []byte } func (md *MarkdownDoc) Extract(source []byte) error { r := bytes.NewReader(source) rest, err := frontmatter.Parse(r, &md.Frontmatter) if err != nil { return err } md.Body = rest return nil } |