Only show blog content preview in blog index when there are few posts

Partially resolves issue #30
This commit is contained in:
Asaf Gartner 2022-06-14 20:15:16 +03:00
parent 2012328436
commit 86a7128f25
2 changed files with 14 additions and 10 deletions

View File

@ -20,15 +20,17 @@
<div class="details">
<a class="user" href="{{ .Author.ProfileUrl }}">{{ .Author.Name }}</a> &mdash; {{ timehtml (relativedate .Date) .Date }}
</div>
<div class="overflow-hidden mh-5 mt2 relative">
<div>
{{ .Content }}
</div>
<div class="excerpt-fade absolute w-100 h4 bottom-0 z-999"></div>
</div>
<div class="mt2">
<a href="{{ .Url }}">Read More &rarr;</a>
</div>
{{ if $.ShowContent }}
<div class="overflow-hidden mh-5 mt2 relative">
<div>
{{ .Content }}
</div>
<div class="excerpt-fade absolute w-100 h4 bottom-0 z-999"></div>
</div>
<div class="mt2">
<a href="{{ .Url }}">Read More &rarr;</a>
</div>
{{ end }}
</div>
</div>
{{ end }}

View File

@ -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)