Redmage/views/homeview/homeview.templ

49 lines
1.3 KiB
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"
import "github.com/tigorlazuardi/redmage/views/utils"
import "time"
2024-04-09 16:09:08 +07:00
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) {
2024-04-29 15:18:23 +07:00
@HomeContent(c, data)
2024-04-09 16:09:08 +07:00
}
}
2024-04-08 16:59:42 +07:00
}
2024-04-09 16:09:08 +07:00
2024-04-29 15:18:23 +07:00
// HomeContent returns the main content of the home page.
//
// Use this template if request is HX-Boosted.
templ HomeContent(_ *views.Context, data Data) {
<main id="main" class="prose">
@components.Container() {
if data.Error != "" {
@components.ErrorToast(data.Error)
} else {
<section class="mb-4 mx-auto">
<h1>Recently Added</h1>
for _, recently := range data.RecentlyAddedImages {
<h2>{ recently.Device.Name }</h2>
for _, subreddit := range recently.Subreddits {
<h4>{ subreddit.Subreddit.Name }</h4>
@RecentlyAddedImageList(subreddit.Images, 0)
}
}
</section>
<section>
<h1>Subreddits</h1>
for _, subreddit := range data.SubredditsList.Data {
<h3>
{ subreddit.Name } -
@utils.RelativeTimeNode(subreddit.Name, utils.NextScheduleTime(subreddit.Schedule).Format(time.RFC3339))
</h3>
}
</section>
2024-04-09 21:49:23 +07:00
}
2024-04-29 15:18:23 +07:00
}
</main>
2024-04-09 16:09:08 +07:00
}