make robots.txt rendering a simple string thing.

This commit is contained in:
fiatjaf
2023-10-18 22:13:12 -03:00
parent 7293103fc7
commit 4b1dddebae
3 changed files with 6 additions and 13 deletions

View File

@@ -78,7 +78,6 @@ func main() {
"relay_sitemap": "sitemap.xml", "relay_sitemap": "sitemap.xml",
"archive": "archive.html", "archive": "archive.html",
"archive_sitemap": "sitemap.xml", "archive_sitemap": "sitemap.xml",
"robots": "robots.txt",
} }
funcMap := template.FuncMap{ funcMap := template.FuncMap{

View File

@@ -1,17 +1,16 @@
package main package main
import ( import (
"fmt"
"net/http" "net/http"
) )
func renderRobots(w http.ResponseWriter, r *http.Request) { func renderRobots(w http.ResponseWriter, r *http.Request) {
typ := "robots"
w.Header().Set("Cache-Control", "max-age=3600") w.Header().Set("Cache-Control", "max-age=3600")
fmt.Fprintf(w, `User-agent: *
Allow: /
params := map[string]any{} Sitemap: https://{{%s}}/npubs-archive.xml
Sitemap: https://{{%s}}/relays-archive.xml
if err := tmpls.ExecuteTemplate(w, templateMapping[typ], params); err != nil { `, s.CanonicalHost, s.CanonicalHost)
log.Error().Err(err).Msg("error rendering")
return
}
} }

View File

@@ -1,5 +0,0 @@
User-agent: *
Allow: /
Sitemap: https://{{s.CanonicalHost}}/npubs-archive.xml
Sitemap: https://{{s.CanonicalHost}}/relays-archive.xml