all repos — vite @ 2da46ab547d9fad7d037e196e49202aa2c2ad517

a fast (this time, actually) and minimal static site generator

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}