Initial commit
This commit is contained in:
commit
e3da3b9c7a
9 changed files with 929 additions and 0 deletions
36
template.go
Normal file
36
template.go
Normal 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)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue