diff --git a/config.go b/config.go index 7cdbeeb..82372d5 100644 --- a/config.go +++ b/config.go @@ -35,33 +35,33 @@ func (t Task) Format(p *Page) (string, []byte) { return t.postProcess.Format(p) } -// LoadConfig loads the configuration from the provided path. -func LoadConfig(path string) (*Config, error) { +// DefaultConfig returns the default configuration. +func DefaultConfig() *Config { c := new(Config) c.Feeds = make(map[string]string) c.Tasks = make(map[string]*Task) + c.Tasks["gemini"] = &Task{ + Input: ".gmi", + Output: ".gmi", + Template: ".gmi", + Destination: "public", + } + return c +} +// LoadConfig loads the configuration from the provided path. +func LoadConfig(path string) (*Config, error) { f, err := os.Open(path) if err != nil { return nil, err } defer f.Close() + c := DefaultConfig() if _, err := toml.DecodeReader(f, c); err != nil { return nil, err } - // Add default task - // The toml library overwrites the map, so add default values after parsing - if _, ok := c.Tasks["gemini"]; !ok { - c.Tasks["gemini"] = &Task{ - Input: ".gmi", - Output: ".gmi", - Template: ".gmi", - Destination: "public", - } - } - for _, task := range c.Tasks { switch task.PostProcess { case "":