weiro/providers/sitebuilder/tmpls.go

59 lines
1.1 KiB
Go
Raw Permalink Normal View History

2026-02-18 11:07:18 +00:00
package sitebuilder
import (
"html/template"
"io/fs"
"time"
"lmika.dev/lmika/weiro/models"
2026-02-19 10:21:27 +00:00
"lmika.dev/lmika/weiro/models/pubmodel"
2026-02-18 11:07:18 +00:00
)
const (
// Template names
// tmplNamePostSingle is the template for single post (postSingleData)
tmplNamePostSingle = "posts_single.html"
// tmplNamePostList is the template for list of posts (postListData)
tmplNamePostList = "posts_list.html"
// tmplNameLayoutMain is the template for the main layout (layoutMainData)
tmplNameLayoutMain = "layout_main.html"
)
type Options struct {
// BasePosts is the base path for posts.
BasePosts string
// TemplatesFS provides the raw templates for rendering the site.
TemplatesFS fs.FS
2026-03-05 11:04:24 +00:00
// FeedItems holds the number of posts to show in the feed.
FeedItems int
2026-02-18 11:07:18 +00:00
RenderTZ *time.Location
}
type commonData struct {
2026-02-19 10:21:27 +00:00
Site pubmodel.Site
}
2026-02-18 11:07:18 +00:00
type postSingleData struct {
commonData
2026-03-05 11:04:24 +00:00
Post *models.Post
HTML template.HTML
Path string
PostURL string
2026-02-18 11:07:18 +00:00
}
type postListData struct {
commonData
2026-02-18 11:07:18 +00:00
Posts []postSingleData
}
type layoutData struct {
commonData
2026-02-18 11:07:18 +00:00
Body template.HTML
}