aboutsummaryrefslogtreecommitdiff
path: root/internal/front/front_test.go
blob: 42094f50d9488390b9dba1bac8128747ed8012a6 (plain)
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package front_test

import (
	"fmt"
	"log"

	"christine.website/internal/front"
)

var markdown = []byte(`---
title: Ferrets
authors:
  - Tobi
  - Loki
  - Jane
---
Some content here, so
interesting, you just
want to keep reading.`)

type article struct {
	Title   string
	Authors []string
}

func Example() {
	var a article

	content, err := front.Unmarshal(markdown, &a)
	if err != nil {
		log.Fatalf("error unmarshalling: %s", err)
	}

	fmt.Printf("%#v\n", a)
	fmt.Printf("%s\n", string(content))
	// Output:
	// front_test.article{Title:"Ferrets", Authors:[]string{"Tobi", "Loki", "Jane"}}
	//
	// Some content here, so
	// interesting, you just
	// want to keep reading.
}