Initial commit

This commit is contained in:
Ivan 2025-06-16 13:50:33 +05:00
commit e3da3b9c7a
Signed by: landlord
GPG key ID: 416A03BC4ADA4CD7
9 changed files with 929 additions and 0 deletions

36
template.go Normal file
View file

@ -0,0 +1,36 @@
package sitemap
import "text/template"
const (
templateText = `<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
{{ range . }}
<url>
<loc>{{ .Loc }}</loc>
{{ if .ChangeFreq }}
<changefreq>{{ .ChangeFreq }}</changefreq>
{{ end }}
{{ if .Priority }}
<priority>{{ .Priority }}</priority>
{{ end }}
{{ if .LastMod }}
<lastmod>{{ .LastMod }}</lastmod>
{{ end }}
</url>
{{ end }}
</urlset>
`
)
var (
parsedTemplate *template.Template
parsingError error
)
func init() {
// Try to parse the sitemap template, but defer error checking until execution.
parsedTemplate, parsingError = template.New("sitemap").Parse(templateText)
}