2022-07-21 17:02:37 +00:00
|
|
|
package kiss
|
|
|
|
|
2022-07-21 17:44:07 +00:00
|
|
|
import "strings"
|
|
|
|
|
|
|
|
func RenderPost(post Post) (string, error) {
|
|
|
|
template, _ := post.user.Template()
|
|
|
|
buf, _ := post.MarkdownData()
|
|
|
|
postHtml := "<h1>" + post.Title() + "</h1>\n"
|
|
|
|
postHtml += buf.String()
|
|
|
|
return strings.Replace(template, "{{content}}", postHtml, -1), nil
|
2022-07-21 17:02:37 +00:00
|
|
|
}
|
2022-07-23 15:19:47 +00:00
|
|
|
|
|
|
|
func RenderIndexPage(user User) (string, error) {
|
|
|
|
template, _ := user.Template()
|
|
|
|
posts, _ := user.Posts()
|
|
|
|
postHtml := ""
|
|
|
|
for _, postId := range posts {
|
|
|
|
post, _ := user.GetPost(postId)
|
|
|
|
postHtml += "<h2><a href=\"" + post.Path() + "\">" + post.Title() + "</a></h2>\n"
|
|
|
|
}
|
|
|
|
return strings.Replace(template, "{{content}}", postHtml, -1), nil
|
|
|
|
}
|