all repos — vite @ 0a2b893a2ec830c9de1a0e25555e9068820eef65

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

config.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
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
package main

import (
	"gopkg.in/yaml.v2"
	"io/ioutil"
)

type Config struct {
	Title        string            `yaml:"title"`
	Header       string            `yaml:"header"`
	DateFmt      string            `yaml:datefmt`
	SiteURL      string            `yaml:"siteurl"`
	Description  string            `yaml:"description"`
	Author       map[string]string `yaml:"author"`
	Footer       string            `yaml:"footer"`
	Prebuild     []string          `yaml:"prebuild"`
	Postbuild    []string          `yaml:"postbuild"`
	RSSPrefixURL string            `yaml:"rssprefixurl"`
}

func parseConfig() Config {
	var config Config
	cf, err := ioutil.ReadFile("config.yaml")
	if err != nil {
		printErr(err)
	}

	err = yaml.Unmarshal(cf, &config)
	if err != nil {
		printErr(err)
	}

	return config
}