Only show blog content preview in blog index when there are few posts
Partially resolves issue #30
This commit is contained in:
parent
2012328436
commit
86a7128f25
|
@ -20,6 +20,7 @@
|
||||||
<div class="details">
|
<div class="details">
|
||||||
<a class="user" href="{{ .Author.ProfileUrl }}">{{ .Author.Name }}</a> — {{ timehtml (relativedate .Date) .Date }}
|
<a class="user" href="{{ .Author.ProfileUrl }}">{{ .Author.Name }}</a> — {{ timehtml (relativedate .Date) .Date }}
|
||||||
</div>
|
</div>
|
||||||
|
{{ if $.ShowContent }}
|
||||||
<div class="overflow-hidden mh-5 mt2 relative">
|
<div class="overflow-hidden mh-5 mt2 relative">
|
||||||
<div>
|
<div>
|
||||||
{{ .Content }}
|
{{ .Content }}
|
||||||
|
@ -29,6 +30,7 @@
|
||||||
<div class="mt2">
|
<div class="mt2">
|
||||||
<a href="{{ .Url }}">Read More →</a>
|
<a href="{{ .Url }}">Read More →</a>
|
||||||
</div>
|
</div>
|
||||||
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
|
@ -30,11 +30,12 @@ func BlogIndex(c *RequestContext) ResponseData {
|
||||||
Posts []blogIndexEntry
|
Posts []blogIndexEntry
|
||||||
Pagination templates.Pagination
|
Pagination templates.Pagination
|
||||||
|
|
||||||
|
ShowContent bool
|
||||||
CanCreatePost bool
|
CanCreatePost bool
|
||||||
NewPostUrl string
|
NewPostUrl string
|
||||||
}
|
}
|
||||||
|
|
||||||
const postsPerPage = 5
|
const postsPerPage = 20
|
||||||
|
|
||||||
numThreads, err := hmndata.CountThreads(c.Context(), c.Conn, c.CurrentUser, hmndata.ThreadsQuery{
|
numThreads, err := hmndata.CountThreads(c.Context(), c.Conn, c.CurrentUser, hmndata.ThreadsQuery{
|
||||||
ProjectIDs: []int{c.CurrentProject.ID},
|
ProjectIDs: []int{c.CurrentProject.ID},
|
||||||
|
@ -105,6 +106,7 @@ func BlogIndex(c *RequestContext) ResponseData {
|
||||||
NextUrl: c.UrlContext.BuildBlog(utils.IntClamp(1, page+1, numPages)),
|
NextUrl: c.UrlContext.BuildBlog(utils.IntClamp(1, page+1, numPages)),
|
||||||
},
|
},
|
||||||
|
|
||||||
|
ShowContent: len(entries) <= 5,
|
||||||
CanCreatePost: canCreate,
|
CanCreatePost: canCreate,
|
||||||
NewPostUrl: c.UrlContext.BuildBlogNewThread(),
|
NewPostUrl: c.UrlContext.BuildBlogNewThread(),
|
||||||
}, c.Perf)
|
}, c.Perf)
|
||||||
|
|
Loading…
Reference in New Issue