-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
config.go
51 lines (39 loc) · 1.14 KB
/
config.go
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
43
44
45
46
47
48
49
50
51
package staticgen
import (
"github.com/tj/go-config"
)
// Config is the static website generator configuration.
type Config struct {
// URL is the target website to crawl. Defaults to "http://127.0.0.1:3000".
URL string `json:"url"`
// Dir is the static website output directory. Defaults to "build".
Dir string `json:"dir"`
// Command is the optional server command executed before crawling.
Command string `json:"command"`
// Pages is a list of paths added to crawl, typically
// including unlinked pages such as error pages,
// landing pages and so on.
Pages []string `json:"pages"`
// Concurrency is the number of concurrent pages to crawl. Defaults to 30.
Concurrency int `json:"concurrency"`
// Allow404 can be enabled to opt-in to pages resulting in a 404,
// which otherwise lead to an error.
Allow404 bool `json:"allow_404"`
}
// Load configuration from the given path.
func (c *Config) Load(path string) error {
if c.URL == "" {
c.URL = "http://127.0.0.1:3000"
}
if c.Dir == "" {
c.Dir = "build"
}
if c.Concurrency == 0 {
c.Concurrency = 30
}
err := config.Load(path, c)
if err != nil {
return err
}
return nil
}