Organize threads into board

This commit is contained in:
Dominic Ferrando
2025-04-19 14:50:28 -04:00
parent 399d2b969d
commit 656595e47e
2 changed files with 24 additions and 27 deletions
+24
View File
@@ -3,6 +3,7 @@ package views
import (
"fmt"
"github.com/dominicf2001/comfychan/internal/database"
"github.com/dominicf2001/comfychan/internal/util"
"github.com/dominicf2001/comfychan/web/views/shared"
)
@@ -60,3 +61,26 @@ templ Board(board database.Board) {
<div hx-get={ fmt.Sprintf("/hx/%s/catalog", board.Slug) } hx-trigger="load, refreshThreads from:body"></div>
}
}
type CatalogThreadPreview struct {
Subject string
Body string
ThreadURL string
MediaPath string
}
templ ThreadsCatalog(previews []CatalogThreadPreview) {
<div id="catalog">
for _, preview := range previews {
<div class="catalog-preview">
<a href={ templ.URL(preview.ThreadURL) }>
<img class="catalog-preview-img" src={ fmt.Sprintf("/static/img/posts/%s", preview.MediaPath) }/>
</a>
<h1><a href={ templ.URL(preview.ThreadURL) } class="catalog-preview-link">{ preview.Subject }</a></h1>
<p>
@templ.Raw(util.EnrichPost(preview.Body))
</p>
</div>
}
</div>
}