// templates/index.go
package templates
import (
"bytes"
"html/template"
"time"
)
// PostSnippet represents data needed for the index list
type PostSnippet struct {
Title string
URL string
Date time.Time
}
// RenderLatestPosts generates the HTML for the list of recent posts.
func RenderLatestPosts(posts []PostSnippet) string {
const tpl = `
Latest Posts
{{range .}}
- {{.Date.Format "Jan 02, 2006"}} {{.Title}}
{{end}}
`
t := template.Must(template.New("latest").Parse(tpl))
var buf bytes.Buffer
if err := t.Execute(&buf, posts); err != nil {
return ""
}
return buf.String()
}
// RenderDirectoryLink generates the navigation link to the full archive.
func RenderDirectoryLink() string {
return ``
}
func RenderTopBanner(content string) string {
return content
}