use template for post list

This commit is contained in:
Niko Abeler 2022-08-18 21:09:02 +02:00
parent a9e83e1c60
commit 3c6df116fa
2 changed files with 6 additions and 3 deletions

View File

@ -0,0 +1,3 @@
{{range .}}
<h2><a href="{{.UrlPath}}">{{.Title}}</a></h2>
{{end}}

View File

@ -86,9 +86,9 @@ func RenderPost(post Post) (string, error) {
func RenderIndexPage(user User) (string, error) { func RenderIndexPage(user User) (string, error) {
posts, _ := user.Posts() posts, _ := user.Posts()
postHtml := "" postHtml, err := renderEmbedTemplate("embed/post-list.html", posts)
for _, post := range posts { if err != nil {
postHtml += "<h2><a href=\"" + post.UrlPath() + "\">" + post.Title() + "</a></h2>\n" return "", err
} }
data := PageContent{ data := PageContent{