initial commit - added base, need to fix templ errors

This commit is contained in:
2025-08-17 10:58:31 +00:00
commit 59d82ae563
20 changed files with 1512 additions and 0 deletions

57
templates/posts.templ Normal file
View File

@@ -0,0 +1,57 @@
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>
}