Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
porozhnyy committed Jan 31, 2023
1 parent 3f9fe6e commit 2ac04d1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
7 changes: 4 additions & 3 deletions stm/builder_url.go
Expand Up @@ -26,13 +26,13 @@ type URLModel struct {
News string `valid:"-"`
Mobile bool `valid:"-"`
Alternate string `valid:"-"`
Alternates map[string]interface{} `valid:"-"`
Alternates map[string]interface{} `valid:"-" structs:"xhtml:link"`
Pagemap map[string]interface{} `valid:"-"`
}

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

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

if su.opts.pretty {
doc.Indent(2)
Expand Down
3 changes: 3 additions & 0 deletions stm/sitemap_test.go
Expand Up @@ -15,6 +15,9 @@ func TestSitemapGenerator(t *testing.T) {
sm.SetPretty(true)
sm.SetVerbose(false)
sm.SetAdapter(&buf)
sm.opts.SetOmitDefaultChangeFreq(false)
sm.opts.SetOmitDefaultPriority(false)
sm.opts.SetOmitDefaultLastMod(false)

sm.Create()
for i := 1; i <= 10; i++ {
Expand Down
6 changes: 3 additions & 3 deletions stm/utils.go
Expand Up @@ -161,9 +161,9 @@ func MergeMap(src, dst [][]interface{}) [][]interface{} {
return src
}

// ToLowerString converts lower strings from including capital or upper strings.
func ToLowerString(befores []string) (afters []string) {
for _, name := range befores {
// KeysToLowerString converts lower strings from including capital or upper strings.
func KeysToLowerString(befores map[string]interface{}) (afters []string) {
for name := range befores {
afters = append(afters, strings.ToLower(name))
}
return afters
Expand Down

0 comments on commit 2ac04d1

Please sign in to comment.