-
Notifications
You must be signed in to change notification settings - Fork 7
/
options.go
61 lines (51 loc) · 1.02 KB
/
options.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
52
53
54
55
56
57
58
59
60
61
package gositemap
import (
"os"
"path"
)
const (
// MaxSitemapLinks defines max links per sitemap
MaxSitemapLinks = 50000
)
type options struct {
defaultHost string
publicPath string
filename string
compress bool
pretty bool
maxLinks int
}
func NewOptions() *options {
pwd, _ := os.Getwd()
return &options{
defaultHost: "http://www.example.com",
publicPath: pwd,
filename: "sitemap.xml",
compress: false,
pretty: false,
maxLinks: MaxSitemapLinks,
}
}
func (o *options) SetDefaultHost(host string) {
o.defaultHost = host
}
func (o *options) SetPublicPath(path string) {
o.publicPath = path
}
func (o *options) SetFilename(filename string) {
if path.Ext(filename) != ".xml" {
filename = filename + ".xml"
}
o.filename = filename
}
func (o *options) SetCompress(compress bool) {
o.compress = compress
}
func (o *options) SetPretty(pretty bool) {
o.pretty = pretty
}
func (o *options) SetMaxLinks(max int) {
if max < MaxSitemapLinks && max > 0 {
o.maxLinks = max
}
}