package sitebuilder
import (
"html/template"
"io/fs"
"time"
"lmika.dev/lmika/weiro/models"
"lmika.dev/lmika/weiro/models/pubmodel"
)
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"
// tmplNameCategoryList is the template for the category index page
tmplNameCategoryList = "categories_list.html"
// tmplNameCategorySingle is the template for a single category page
tmplNameCategorySingle = "categories_single.html"
// tmplNamePageSingle is the template for a single page (pageSingleData)
tmplNamePageSingle = "pages_single.html"
)
type Options struct {
BasePosts string // BasePosts is the base path for posts.
BasePostList string // BasePostList is the base path for post lists.
BaseUploads string // BaseUploads is the base path for uploads.
BaseStatic string // BaseStatic is the base path for static assets.
// TemplatesFS provides the raw templates for rendering the site.
TemplatesFS fs.FS
// StaticFS provides the raw assets for the site. This will be written as is
// from the BaseStatic dir.
StaticFS fs.FS
// FeedItems holds the number of posts to show in the feed.
FeedItems int
RenderTZ *time.Location
}
type commonData struct {
Site pubmodel.Site
}
type postSingleData struct {
commonData
Post *models.Post
HTML template.HTML
Path string
PostURL string
Categories []*models.Category
}
type postListData struct {
commonData
Posts []postSingleData
PageInfo models.PageInfo
PrevURL string
NextURL string
}
type layoutData struct {
commonData
Body template.HTML
}
type categoryListData struct {
commonData
Categories []categoryListItem
}
type categoryListItem struct {
models.CategoryWithCount
Path string
}
type categorySingleData struct {
commonData
Category *models.Category
DescriptionHTML template.HTML
Posts []postSingleData
Path string
PageInfo models.PageInfo
PrevURL string
NextURL string
}
type pageSingleData struct {
commonData
Page *models.Page
HTML template.HTML
}