Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for alternate links #45

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions stm/builder_url.go
Original file line number Diff line number Diff line change
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
6 changes: 3 additions & 3 deletions stm/utils.go
Original file line number Diff line number Diff line change
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