mirror of https://github.com/jlelse/GoBlog
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
513 B
Go
22 lines
513 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
)
|
|
|
|
const robotsTXTPath = "/robots.txt"
|
|
|
|
func (a *goBlog) serveRobotsTXT(w http.ResponseWriter, _ *http.Request) {
|
|
_, _ = fmt.Fprint(w, "User-agent: *\n")
|
|
if a.isPrivate() {
|
|
_, _ = fmt.Fprint(w, "Disallow: /\n")
|
|
return
|
|
}
|
|
_, _ = 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)))
|
|
}
|
|
}
|