Redmage/views/homeview/homeview.templ

40 lines
859 B
Plaintext
Raw Normal View History

2024-04-08 16:59:42 +07:00
package homeview
import "github.com/tigorlazuardi/redmage/views/components"
import "github.com/tigorlazuardi/redmage/views"
2024-04-09 16:09:08 +07:00
import "github.com/tigorlazuardi/redmage/api"
2024-04-09 16:09:08 +07:00
type Data struct {
SubredditsList api.ListSubredditsResult
Error error
}
templ Home(c *views.Context, data Data) {
@components.Doctype() {
2024-04-09 21:49:23 +07:00
@components.Head(c, components.HeadTitle("Redmage - Home"))
2024-04-09 16:09:08 +07:00
@components.Body(c) {
@components.Container() {
if data.Error != nil {
@components.ErrorToast(data.Error.Error())
} else {
@home(c, data)
}
}
}
}
2024-04-08 16:59:42 +07:00
}
2024-04-09 16:09:08 +07:00
templ home(c *views.Context, data Data) {
<div class="prose">
2024-04-09 21:49:23 +07:00
<section>
<h1>Recently Added</h1>
</section>
<section>
<h1>Subreddits</h1>
for _, subreddit := range data.SubredditsList.Data {
<h3>{ subreddit.Name } - { subreddit.Schedule }</h3>
}
</section>
2024-04-09 16:09:08 +07:00
</div>
}