diff options
Diffstat (limited to 'internal/web/handlers_blog.go')
| -rw-r--r-- | internal/web/handlers_blog.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/internal/web/handlers_blog.go b/internal/web/handlers_blog.go index c26adfa..c1afedb 100644 --- a/internal/web/handlers_blog.go +++ b/internal/web/handlers_blog.go @@ -63,6 +63,10 @@ func (s *Server) blogView(r *http.Request) (map[string]any, error) { return v, nil } +// noNotices stands in for the placed announcements on pages that hide them +// (typed, so the layout's index lookups still work). +var noNotices = map[string][]store.Section{} + // pageNum reads the ?p= of a paginated listing (1 when absent or silly). func pageNum(r *http.Request) int { n, _ := strconv.Atoi(r.URL.Query().Get("p")) @@ -109,6 +113,9 @@ func (s *Server) renderPage(w http.ResponseWriter, r *http.Request, page *store. last := (total + per - 1) / per fillExcerpts(v["theme"].(Theme), posts) v["page"], v["posts"], v["pageNum"], v["lastPage"] = page, posts, n, last + if !page.ShowNotices { + v["notices"] = noNotices + } // The pager appends ?p=N to base: no trailing slash, which /{page} would not match. v["base"] = "/" + page.Slug if page.IsHome { @@ -195,6 +202,11 @@ func (s *Server) handleBlogPost(w http.ResponseWriter, r *http.Request) { return } v["page"], v["post"] = page, post + // A post shows the announcements only when its page does and the theme + // wants them on posts at all. + if !page.ShowNotices || !v["theme"].(Theme).PostNotices { + v["notices"] = noNotices + } s.render(w, r, "blog/post.html", v) } |
