simplified some loops, added day2.md to test new footer date functionality

This commit is contained in:
2026-03-10 23:59:17 +00:00
parent 18d151e0cf
commit 4ef81c59bf
8 changed files with 83 additions and 23 deletions

View File

@@ -8,7 +8,17 @@ package templates
import "github.com/a-h/templ"
import templruntime "github.com/a-h/templ/runtime"
import "git.valxntine.dev/valxntine/blog/models"
import (
"git.valxntine.dev/valxntine/blog/models"
"time"
)
func GetLastUpdated(p []models.Post) time.Time {
if len(p) == 0 {
return time.Time{}
}
return p[0].PublishedAt
}
func HomePage(data models.Data) templ.Component {
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
@@ -67,7 +77,7 @@ func HomePage(data models.Data) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = Footer().Render(ctx, templ_7745c5c3_Buffer)
templ_7745c5c3_Err = Footer(GetLastUpdated(data.Posts)).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}