mirror of
https://github.com/aljazceru/njump.git
synced 2025-12-17 22:34:25 +01:00
sitemaps of sitemaps of profile sitemaps.
This commit is contained in:
29
render_sitemap_index.go
Normal file
29
render_sitemap_index.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/nbd-wtf/go-nostr/nip19"
|
||||
)
|
||||
|
||||
func renderSitemapIndex(w http.ResponseWriter, r *http.Request) {
|
||||
npubs := make([]string, 0, 5000)
|
||||
keys := cache.GetPaginatedKeys("pa:", 1, 5000)
|
||||
for _, key := range keys {
|
||||
npub, _ := nip19.EncodePublicKey(key[3:])
|
||||
npubs = append(npubs, npub)
|
||||
}
|
||||
|
||||
if len(npubs) != 0 {
|
||||
w.Header().Set("Cache-Control", "max-age=3600")
|
||||
} else {
|
||||
w.Header().Set("Cache-Control", "max-age=60")
|
||||
}
|
||||
|
||||
w.Header().Add("content-type", "text/xml")
|
||||
w.Write([]byte(XML_HEADER))
|
||||
SitemapIndexTemplate.Render(w, &SitemapIndexPage{
|
||||
Host: s.Domain,
|
||||
Npubs: npubs,
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user