config.go (view raw)
1package main
2
3import (
4 "gopkg.in/yaml.v2"
5 "io/ioutil"
6)
7
8type Config struct {
9 Title string `yaml:"title"`
10 Header string `yaml:"header"`
11 DateFmt string `yaml:datefmt`
12 SiteURL string `yaml:"siteurl"`
13 Description string `yaml:"description"`
14 Author map[string]string `yaml:"author"`
15 Footer string `yaml:"footer"`
16 Prebuild []string `yaml:"prebuild"`
17 Postbuild []string `yaml:"postbuild"`
18 RSSPrefixURL string `yaml:"rssprefixurl"`
19}
20
21func parseConfig() Config {
22 var config Config
23 cf, err := ioutil.ReadFile("config.yaml")
24 if err != nil {
25 printErr(err)
26 }
27
28 err = yaml.Unmarshal(cf, &config)
29 if err != nil {
30 printErr(err)
31 }
32
33 return config
34}