1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-21 03:47:04 +00:00

add Route.ExcludeSitemap method to exclude a route from sitemap, also exclude the offline routes as requested

This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-08-29 01:21:42 +03:00
parent 6f9a453160
commit 00684f9d2e
4 changed files with 22 additions and 2 deletions

View File

@@ -68,6 +68,7 @@ type Route struct {
overlappedLink *Route
// Sitemap properties: https://www.sitemaps.org/protocol.html
NoSitemap bool // when this route should be hidden from sitemap.
LastMod time.Time `json:"lastMod,omitempty"`
ChangeFreq string `json:"changeFreq,omitempty"`
Priority float32 `json:"priority,omitempty"`
@@ -238,6 +239,16 @@ func (r *Route) DeepEqual(other *Route) bool {
return r.Equal(other) && r.tmpl.Src == other.tmpl.Src
}
// ExcludeSitemap excludes this route page from sitemap generator.
// It sets the NoSitemap field to true.
//
// See `SetLastMod`, `SetChangeFreq`, `SetPriority` methods
// and `iris.WithSitemap`.
func (r *Route) ExcludeSitemap() *Route {
r.NoSitemap = true
return r
}
// SetLastMod sets the date of last modification of the file served by this static GET route.
func (r *Route) SetLastMod(t time.Time) *Route {
r.LastMod = t