Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
ec86a0396a | |||
ccf681abfc |
@@ -4,6 +4,7 @@ import (
|
||||
"encoding/xml"
|
||||
"fmt"
|
||||
"math"
|
||||
"path"
|
||||
)
|
||||
|
||||
type ChangeFrequency string
|
||||
@@ -51,7 +52,7 @@ type SiteMap struct {
|
||||
|
||||
func (m *SiteMap) AddURL(url string, lastMod *string, freq *ChangeFrequency, prio *float64) {
|
||||
m.urls = append(m.urls, &urlXML{
|
||||
Loc: fmt.Sprintf("https://%s/%s", m.BaseURL, url),
|
||||
Loc: fmt.Sprintf("https://%s", path.Join(m.BaseURL, url)),
|
||||
LastMod: lastMod,
|
||||
ChangeFreq: freq,
|
||||
Priority: prio,
|
||||
@@ -69,7 +70,7 @@ func (m *SiteMap) SiteMapIndex() ([]byte, error) {
|
||||
|
||||
for i := 0; i < nSiteMaps; i++ {
|
||||
index.SiteMaps = append(index.SiteMaps, &sitemapXML{
|
||||
Loc: fmt.Sprintf("https://%s/sitemap%d.xml", m.BaseURL, i),
|
||||
Loc: fmt.Sprintf("https://%s/sitemap/%d", m.BaseURL, i),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -82,6 +83,10 @@ func (m *SiteMap) SiteMapIndex() ([]byte, error) {
|
||||
}
|
||||
|
||||
func (m *SiteMap) SiteMap(id int) ([]byte, error) {
|
||||
if 50000*(id) >= len(m.urls) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
siteMap := &urlSetXML{}
|
||||
|
||||
var urls []*urlXML
|
||||
|
Reference in New Issue
Block a user