From 86a7128f251d21f39c3e4c920855414d4fce0150 Mon Sep 17 00:00:00 2001 From: Asaf Gartner Date: Tue, 14 Jun 2022 20:15:16 +0300 Subject: [PATCH] Only show blog content preview in blog index when there are few posts Partially resolves issue #30 --- src/templates/src/blog_index.html | 20 +++++++++++--------- src/website/blogs.go | 4 +++- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/templates/src/blog_index.html b/src/templates/src/blog_index.html index 177b8a0..6ead85b 100644 --- a/src/templates/src/blog_index.html +++ b/src/templates/src/blog_index.html @@ -20,15 +20,17 @@
{{ .Author.Name }} — {{ timehtml (relativedate .Date) .Date }}
-
-
- {{ .Content }} -
-
-
-
- Read More → -
+ {{ if $.ShowContent }} +
+
+ {{ .Content }} +
+
+
+
+ Read More → +
+ {{ end }} {{ end }} diff --git a/src/website/blogs.go b/src/website/blogs.go index 3e92e21..a14e828 100644 --- a/src/website/blogs.go +++ b/src/website/blogs.go @@ -30,11 +30,12 @@ func BlogIndex(c *RequestContext) ResponseData { Posts []blogIndexEntry Pagination templates.Pagination + ShowContent bool CanCreatePost bool NewPostUrl string } - const postsPerPage = 5 + const postsPerPage = 20 numThreads, err := hmndata.CountThreads(c.Context(), c.Conn, c.CurrentUser, hmndata.ThreadsQuery{ ProjectIDs: []int{c.CurrentProject.ID}, @@ -105,6 +106,7 @@ func BlogIndex(c *RequestContext) ResponseData { NextUrl: c.UrlContext.BuildBlog(utils.IntClamp(1, page+1, numPages)), }, + ShowContent: len(entries) <= 5, CanCreatePost: canCreate, NewPostUrl: c.UrlContext.BuildBlogNewThread(), }, c.Perf)