use template for post list
This commit is contained in:
parent
a9e83e1c60
commit
3c6df116fa
|
@ -0,0 +1,3 @@
|
||||||
|
{{range .}}
|
||||||
|
<h2><a href="{{.UrlPath}}">{{.Title}}</a></h2>
|
||||||
|
{{end}}
|
|
@ -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{
|
||||||
|
|
Loading…
Reference in New Issue