diff options
Diffstat (limited to 'internal/builder/template.go')
-rw-r--r-- | internal/builder/template.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/internal/builder/template.go b/internal/builder/template.go index 5e2af1a..ab36c85 100644 --- a/internal/builder/template.go +++ b/internal/builder/template.go @@ -8,6 +8,7 @@ import ( "os" "strings" "sync" + "text/template" "time" "website/internal/atom" "website/internal/config" @@ -295,6 +296,24 @@ func renderHomepage(config config.Config, posts []Post, url string) (io.Reader, return renderHTML(doc), nil } +func renderRobotsTXT(config config.Config) (io.Reader, error) { + r, w := io.Pipe() + tpl, err := template.ParseFiles("templates/robots.tmpl") + if err != nil { + return nil, err + } + go func() { + err = tpl.Execute(w, map[string]interface{}{ + "BaseURL": config.BaseURL, + }) + if err != nil { + w.CloseWithError(err) + } + w.Close() + }() + return r, nil +} + func render404(config config.Config, url string) (io.Reader, error) { doc, err := layout("templates/404.html", config, "404 Not Found", url) if err != nil { |