all repos — vite @ c5d0a5c35c59e57f460bcaa1f6263e4e3253871f

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}