Organize threads into board
This commit is contained in:
@@ -3,6 +3,7 @@ package views
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/dominicf2001/comfychan/internal/database"
|
"github.com/dominicf2001/comfychan/internal/database"
|
||||||
|
"github.com/dominicf2001/comfychan/internal/util"
|
||||||
"github.com/dominicf2001/comfychan/web/views/shared"
|
"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>
|
<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>
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
package views
|
|
||||||
|
|
||||||
import "fmt"
|
|
||||||
import "github.com/dominicf2001/comfychan/internal/util"
|
|
||||||
|
|
||||||
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>
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user