-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsitemap.go
More file actions
53 lines (43 loc) · 846 Bytes
/
sitemap.go
File metadata and controls
53 lines (43 loc) · 846 Bytes
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
// Copyright (c) CattleCloud LLC
// SPDX-License-Identifier: BSD-3-Clause
package sitemaps
import (
"bytes"
"encoding/xml"
"time"
)
type Site []*URL
type Frequency string
const (
Always Frequency = "always"
Hourly Frequency = "hourly"
Daily Frequency = "daily"
Weekly Frequency = "weekly"
Monthly Frequency = "monthly"
Yearly Frequency = "yearly"
Never Frequency = "never"
)
type Priority float64
const (
Top = 0.9
High = 0.8
Bump = 0.6
Normal = 0.5
Low = 0.2
None = 0.1
)
type URL struct {
Location string
Modified CalendarDay
Frequency Frequency
Priority Priority
}
func EncodeLocation(original string) string {
b := new(bytes.Buffer)
xml.Escape(b, []byte(original))
return b.String()
}
func EncodeUnix(unix int64) CalendarDay {
t := time.Unix(unix, 0).In(time.UTC)
return DayFrom(t)
}