Fix pagination, use blog title and descriptions in feed as fallback

This commit is contained in:
Jan-Lukas Else 2020-09-20 21:37:04 +02:00
parent 8ef592cb22
commit 4393d28186
3 changed files with 11 additions and 9 deletions

View File

@ -18,6 +18,12 @@ const (
func generateFeed(f feedType, w http.ResponseWriter, r *http.Request, posts []*Post, title string, description string) {
now := time.Now()
if title == "" {
title = appConfig.Blog.Title
}
if description == "" {
description = appConfig.Blog.Description
}
feed := &feeds.Feed{
Title: title,
Description: description,

10
http.go
View File

@ -137,11 +137,11 @@ func buildHandler() (http.Handler, error) {
rootPath := "/"
blogPath := "/blog"
if routePatterns := routesToStringSlice(r.Routes()); !routePatterns.has(rootPath) {
r.With(cacheMiddleware, minifier.Middleware).Get(rootPath, serveHome(rootPath, NONE))
r.With(cacheMiddleware, minifier.Middleware).Get(rootPath+rssPath, serveHome(rootPath, RSS))
r.With(cacheMiddleware, minifier.Middleware).Get(rootPath+jsonPath, serveHome(rootPath, JSON))
r.With(cacheMiddleware, minifier.Middleware).Get(rootPath+atomPath, serveHome(rootPath, ATOM))
r.With(cacheMiddleware, minifier.Middleware).Get(paginationPath, serveHome(rootPath, NONE))
r.With(cacheMiddleware, minifier.Middleware).Get(rootPath, serveHome("", NONE))
r.With(cacheMiddleware, minifier.Middleware).Get(rootPath+rssPath, serveHome("", RSS))
r.With(cacheMiddleware, minifier.Middleware).Get(rootPath+jsonPath, serveHome("", JSON))
r.With(cacheMiddleware, minifier.Middleware).Get(rootPath+atomPath, serveHome("", ATOM))
r.With(cacheMiddleware, minifier.Middleware).Get(paginationPath, serveHome("", NONE))
} else if !routePatterns.has(blogPath) {
r.With(cacheMiddleware, minifier.Middleware).Get(blogPath, serveHome(blogPath, NONE))
r.With(cacheMiddleware, minifier.Middleware).Get(blogPath+rssPath, serveHome(blogPath, RSS))

View File

@ -129,10 +129,6 @@ func serveIndex(path string, sec *section, tax *taxonomy, taxonomyValue string,
} else if sec != nil {
title = sec.Title
description = sec.Description
} else if tax == nil && sec == nil {
// Show no title or description on home
// title = appConfig.Blog.Title
// description = appConfig.Blog.Description
}
// Check if feed
if ft != NONE {