package homeview import "github.com/tigorlazuardi/redmage/models" import "github.com/tigorlazuardi/redmage/api/reddit" import "fmt" type ImageCardOption uint func (o ImageCardOption) Has(opt ImageCardOption) bool { return o&opt != 0 } const ( HideTitle ImageCardOption = 1 << iota HideDescription HideSubreddit HidePoster ) templ RecentlyAddedImageCard(data *models.Image, opts ImageCardOption) {
{
if !opts.Has(HideTitle) { { data.Title } } { data.Poster }
if data.R.Subreddit != nil { if !opts.Has(HideSubreddit) { { data.R.Subreddit.Name } } }
} templ RecentlyAddedImageList(images models.ImageSlice, opts ImageCardOption) {
for _, data := range images { @RecentlyAddedImageCard(data, opts) }
}