Support server-rendered index.html for all clients. Closes #1871

This commit is contained in:
Gabe Kangas
2022-06-19 16:35:55 -07:00
parent 78c6189c02
commit ff968616ba
5 changed files with 69 additions and 57 deletions

View File

@@ -36,12 +36,6 @@ func IndexHandler(w http.ResponseWriter, r *http.Request) {
isIndexRequest := r.URL.Path == "/" || filepath.Base(r.URL.Path) == "index.html" || filepath.Base(r.URL.Path) == ""
if isIndexRequest {
serveWeb(w, r)
return
}
// For search engine bots and social scrapers return a special
// server-rendered page.
if utils.IsUserAgentABot(r.UserAgent()) && isIndexRequest {
handleScraperMetadataPage(w, r)
return
}
@@ -78,7 +72,7 @@ func IndexHandler(w http.ResponseWriter, r *http.Request) {
// Return a basic HTML page with server-rendered metadata from the config
// to give to Opengraph clients and web scrapers (bots, web crawlers, etc).
func handleScraperMetadataPage(w http.ResponseWriter, r *http.Request) {
tmpl, err := static.GetBotMetadataTemplate()
tmpl, err := static.GetWebIndexTemplate()
if err != nil {
log.Errorln(err)
w.WriteHeader(http.StatusInternalServerError)