simplified some loops, added day2.md to test new footer date functionality
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user