package sitemap
import (
"io"
"time"
"github.com/snabb/sitemap"
"alin.ovh/homestead/shared/config"
)
type Sitemap struct {
config *config.Config
Sitemap *sitemap.Sitemap
}
func New(cfg *config.Config) *Sitemap {
return &Sitemap{
config: cfg,
Sitemap: sitemap.New(),
}
}
func (s *Sitemap) AddPath(path string, lastMod time.Time) {
url := &sitemap.URL{
Loc: s.config.BaseURL.JoinPath(path).String(),
}
if !lastMod.IsZero() {
url.LastMod = &lastMod
}
s.Sitemap.Add(url)
}
func (s *Sitemap) WriteTo(w io.Writer) (int64, error) {
return s.Sitemap.WriteTo(w)
}
domain/indieweb/sitemap/sitemap.go (view raw)