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",
"archive": "archive.html",
"archive_sitemap": "sitemap.xml",
"robots": "robots.txt",
}
funcMap := template.FuncMap{

View File

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

View File

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