2020-11-09 15:40:12 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
2021-07-27 10:51:08 +00:00
|
|
|
const robotsTXTPath = "/robots.txt"
|
|
|
|
|
2022-02-25 15:29:42 +00:00
|
|
|
func (a *goBlog) serveRobotsTXT(w http.ResponseWriter, _ *http.Request) {
|
2022-02-12 21:29:45 +00:00
|
|
|
_, _ = fmt.Fprint(w, "User-agent: *\n")
|
2021-07-27 10:51:08 +00:00
|
|
|
if a.isPrivate() {
|
2022-02-12 21:29:45 +00:00
|
|
|
_, _ = fmt.Fprint(w, "Disallow: /\n")
|
2021-07-27 10:51:08 +00:00
|
|
|
return
|
|
|
|
}
|
2022-02-12 21:29:45 +00:00
|
|
|
_, _ = fmt.Fprint(w, "Allow: /\n\n")
|
|
|
|
_, _ = fmt.Fprintf(w, "Sitemap: %s\n", a.getFullAddress(sitemapPath))
|
|
|
|
for _, bc := range a.cfg.Blogs {
|
|
|
|
_, _ = fmt.Fprintf(w, "Sitemap: %s\n", a.getFullAddress(bc.getRelativePath(sitemapBlogPath)))
|
|
|
|
}
|
2020-11-09 15:40:12 +00:00
|
|
|
}
|