package views type Post struct { ID string Content string Author string Date string } type Reaction struct { ID string Label string Count string JustChanged bool } type PostStats struct { PostID string Views PostViews Reactions []Reaction } type PostViews struct { Count string JustChanged bool } templ Index(posts []Post) { @base() { @Posts(posts) } } templ Posts(posts []Post) {
for _, p := range posts { @postView(p) }
} templ Idle() {
Paused to save resources. 🫢
Still around?
} templ postView(post Post) {
{ post.Author }
{ post.Date }

{ post.Content }

} templ PostStatsView(stats PostStats) {
👁️ { stats.Views.Count + " views" }
for _, r := range stats.Reactions { @reactionButton(stats.PostID, r) }
} templ reactionButton(postID string, reaction Reaction) {
} templ UpdatedButton(label string) { }