Skip to content

Commit 2ac04d1

Browse files
committed
1 parent 3f9fe6e commit 2ac04d1

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

stm/builder_url.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ type URLModel struct {
2626
News string `valid:"-"`
2727
Mobile bool `valid:"-"`
2828
Alternate string `valid:"-"`
29-
Alternates map[string]interface{} `valid:"-"`
29+
Alternates map[string]interface{} `valid:"-" structs:"xhtml:link"`
3030
Pagemap map[string]interface{} `valid:"-"`
3131
}
3232

3333
// fieldnames []string{"priority" "changefreq" "lastmod" "expires" "host" "images"
34-
// "video" "geo" "news" "videos" "mobile" "alternate" "alternates" "pagemap"}
35-
var fieldnames = ToLowerString(structs.Names(&URLModel{}))
34+
// "video" "geo" "news" "videos" "mobile" "alternate" "xhtml:link" "pagemap"}
35+
var fieldnames = KeysToLowerString(structs.New(&URLModel{}).Map())
3636

3737
// NewSitemapURL returns the created the SitemapURL's pointer
3838
// and it validates URL types error.
@@ -115,6 +115,7 @@ func (su *sitemapURL) XML() []byte {
115115
SetBuilderElementValue(url, su.data, "video")
116116
SetBuilderElementValue(url, su.data, "image")
117117
SetBuilderElementValue(url, su.data, "geo")
118+
SetBuilderElementValue(url, su.data, "xhtml:link")
118119

119120
if su.opts.pretty {
120121
doc.Indent(2)

stm/sitemap_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ func TestSitemapGenerator(t *testing.T) {
1515
sm.SetPretty(true)
1616
sm.SetVerbose(false)
1717
sm.SetAdapter(&buf)
18+
sm.opts.SetOmitDefaultChangeFreq(false)
19+
sm.opts.SetOmitDefaultPriority(false)
20+
sm.opts.SetOmitDefaultLastMod(false)
1821

1922
sm.Create()
2023
for i := 1; i <= 10; i++ {

stm/utils.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,9 @@ func MergeMap(src, dst [][]interface{}) [][]interface{} {
161161
return src
162162
}
163163

164-
// ToLowerString converts lower strings from including capital or upper strings.
165-
func ToLowerString(befores []string) (afters []string) {
166-
for _, name := range befores {
164+
// KeysToLowerString converts lower strings from including capital or upper strings.
165+
func KeysToLowerString(befores map[string]interface{}) (afters []string) {
166+
for name := range befores {
167167
afters = append(afters, strings.ToLower(name))
168168
}
169169
return afters

0 commit comments

Comments
 (0)