// templates/index.go
package templates
import (
"bytes"
"fmt"
"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.
// It accepts a list of posts (already sorted).
func RenderLatestPosts(posts []PostSnippet) string {
var buf bytes.Buffer
buf.WriteString(`
Latest Posts
`)
for _, p := range posts {
dateStr := p.Date.Format("Jan 02, 2006")
buf.WriteString(fmt.Sprintf(`- %s %s
`, dateStr, p.URL, p.Title))
}
buf.WriteString(`
`)
return buf.String()
}
// RenderDirectoryLink generates the navigation link to the full archive.
func RenderDirectoryLink() string {
return ``
}
// RenderSiteHeadline generates the top banner.
func RenderSiteHeadline(text string) string {
return fmt.Sprintf(`%s
`, text)
}