58 lines
1.3 KiB
Plaintext
58 lines
1.3 KiB
Plaintext
package templates
|
|
|
|
import "time"
|
|
|
|
templ PostList(posts []models.Post, page, totalPages int) {
|
|
<div id="post-list">
|
|
<ul class="blog-posts">
|
|
for _, post := range posts {
|
|
@PostListItem(post)
|
|
}
|
|
</ul>
|
|
|
|
if totalPages > 1 {
|
|
@Pagination(page, totalPages)
|
|
}
|
|
</div>
|
|
}
|
|
|
|
templ PostListItem(post models.Post) {
|
|
<li class="blog-post">
|
|
<div class="post-title">
|
|
<a href={ templ.URL("/posts/" + post.Slug) }
|
|
hx-get={ "/posts/" + post.Slug }
|
|
hx-target="main"
|
|
hx-push-url="true">
|
|
{ post.Title }
|
|
</a>
|
|
</div>
|
|
<div class="post-meta">
|
|
Posted: { post.PublishedAt.Format("2006-01-02") } |
|
|
Tags:
|
|
for i, tag := range post.Tags {
|
|
if i > 0 {
|
|
,
|
|
}
|
|
<a href={ templ.URL("/tags/" + tag) }
|
|
hx-get={ "/tags/" + tag }
|
|
hx-target="main"
|
|
hx-push-url="true">
|
|
{ tag }
|
|
</a>
|
|
}
|
|
| Words: { fmt.Sprintf("%d", post.WordCount) }
|
|
</div>
|
|
<div class="post-excerpt">
|
|
{ post.Excerpt }
|
|
</div>
|
|
<div class="read-more">
|
|
<a href={ templ.URL("/posts/" + post.Slug) }
|
|
hx-get={ "/posts/" + post.Slug }
|
|
hx-target="main"
|
|
hx-push-url=true>
|
|
[Read more...]
|
|
</a>
|
|
</div>
|
|
</li>
|
|
}
|