package subredditsview import "github.com/tigorlazuardi/redmage/views" import "github.com/tigorlazuardi/redmage/views/components" import "github.com/tigorlazuardi/redmage/models" import "strconv" import "fmt" templ Subreddit(c *views.Context, data Data) { @components.Doctype() { @components.Head(c, components.HeadTitle("Redmage - Subreddits")) @components.Body(c) { @SubredditContent(c, data) } } } templ SubredditContent(c *views.Context, data Data) {
@components.Container() {

Subreddits

if data.Subreddits.Total == 0 {

No Subreddits Found

Click here to add a new subreddit.

} else {

{ strconv.FormatInt(data.Subreddits.Total, 10) } Subreddits Registered

Add Subreddit
}
for _, subreddit := range data.Subreddits.Data { @SubredditCard(c, subreddit) }
}
} templ SubredditCard(c *views.Context, data *models.Subreddit) { if len(data.R.Images) > 0 {
{
} else {
@imagePlaceholder()
}

{ data.Name }

} templ imagePlaceholder() { }