stdxgit.sr.ht/~pingoo/stdx/sitemap Index | Files

package sitemap

import "git.sr.ht/~pingoo/stdx/sitemap"

Index

Types

type ChangeFreq

type ChangeFreq string

ChangeFreq specifies change frequency of a sitemap entry. It is just a string.

const (
	Always  ChangeFreq = "always"
	Hourly  ChangeFreq = "hourly"
	Daily   ChangeFreq = "daily"
	Weekly  ChangeFreq = "weekly"
	Monthly ChangeFreq = "monthly"
	Yearly  ChangeFreq = "yearly"
	Never   ChangeFreq = "never"
)

type Sitemap

type Sitemap struct {
	XMLName xml.Name `xml:"urlset"`
	Xmlns   string   `xml:"xmlns,attr"`
	Urls    []URL    `xml:"url"`
	// contains filtered or unexported fields
}

func New

func New(minify bool) *Sitemap

New returns a new Sitemap.

func (*Sitemap) Add

func (sitemap *Sitemap) Add(url URL)

Add adds an URL to a Sitemap.

func (*Sitemap) String

func (sitemap *Sitemap) String() (ret string, err error)

func (*Sitemap) WriteTo

func (sitemap *Sitemap) WriteTo(w io.Writer) (err error)

WriteTo writes XML encoded sitemap to given io.Writer. Implements io.WriterTo.

type URL

type URL struct {
	Loc        string     `xml:"loc"`
	LastMod    *time.Time `xml:"lastmod,omitempty"`
	ChangeFreq ChangeFreq `xml:"changefreq,omitempty"`
	Priority   float32    `xml:"priority,omitempty"`
}

Source Files

sitemap.go

Version
v0.0.0-20240218134121-094174641f6e (latest)
Published
Feb 18, 2024
Platform
linux/amd64
Imports
4 packages
Last checked
4 months ago

Tools for package owners.