Documentation
¶
Index ¶
- Variables
- func ComputeAssetHash(theme *Theme) string
- func FormatDate(lang string, t time.Time) string
- func FormatDateTime(lang string, t time.Time) string
- func NewCompositeFSForTest(primary, secondary fs.FS) fs.FS
- func ReadThemeStyles(theme *Theme) (baseCSS, styleCSS string)
- func ResolveFSForTest(theme *Theme, embedded fs.FS, subPath string) fs.FS
- func StaticFiles(theme *Theme) http.Handler
- type AuthPageData
- type AuthorData
- type CommentItem
- type ContentData
- type FormattedField
- type HomeSection
- type IndexData
- type LanguageLink
- type LayoutData
- type NavigationItem
- type NotFoundData
- type PaginationData
- type PostItem
- type ResetPasswordData
- type SiteConfig
- type TagData
- type Templates
- func (t *Templates) RenderAuthor(w http.ResponseWriter, data AuthorData) error
- func (t *Templates) RenderAuthorToString(data AuthorData) (string, error)
- func (t *Templates) RenderContent(w http.ResponseWriter, data ContentData) error
- func (t *Templates) RenderContentToString(data ContentData) (string, error)
- func (t *Templates) RenderForgotPassword(w http.ResponseWriter, data AuthPageData) error
- func (t *Templates) RenderHome(w http.ResponseWriter, data IndexData) error
- func (t *Templates) RenderHomeToString(data IndexData) (string, error)
- func (t *Templates) RenderIndex(w http.ResponseWriter, data IndexData) error
- func (t *Templates) RenderIndexToString(data IndexData) (string, error)
- func (t *Templates) RenderLogin(w http.ResponseWriter, data AuthPageData) error
- func (t *Templates) RenderLoginToString(data AuthPageData) (string, error)
- func (t *Templates) RenderNotFound(w http.ResponseWriter, data NotFoundData) error
- func (t *Templates) RenderNotFoundToString(data NotFoundData) (string, error)
- func (t *Templates) RenderRegister(w http.ResponseWriter, data AuthPageData) error
- func (t *Templates) RenderRegisterToString(data AuthPageData) (string, error)
- func (t *Templates) RenderResetPassword(w http.ResponseWriter, data ResetPasswordData) error
- func (t *Templates) RenderTag(w http.ResponseWriter, data TagData) error
- func (t *Templates) RenderTagToString(data TagData) (string, error)
- func (t *Templates) RenderVerifyEmail(w http.ResponseWriter, data VerifyEmailData) error
- type Theme
- type VerifyEmailData
Constants ¶
This section is empty.
Variables ¶
var LocalizedMonths = map[string][12]string{
"id": {"Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember"},
}
LocalizedMonths maps language codes to their month names. When a language code is present, FormatDate and FormatDateTime use it; otherwise Go's native English formatting is used.
Functions ¶
func ComputeAssetHash ¶ added in v0.6.0
ComputeAssetHash reads base.css and style.css from the resolved static filesystem and returns a short combined hex hash for filename-based cache versioning. When either file is not found (e.g. broken theme), it returns "dev".
func FormatDate ¶ added in v0.6.0
FormatDate returns a human-readable date string for the given time. When lang matches a key in LocalizedMonths, the localized month name is used. Otherwise Go's native English formatting ("January 2, 2006") is used.
func FormatDateTime ¶ added in v0.6.0
FormatDateTime returns a human-readable date+time string for the given time. When lang matches a key in LocalizedMonths, the localized month name is used. Otherwise Go's native English formatting ("January 2, 2006 at 3:04 PM") is used.
func NewCompositeFSForTest ¶
NewCompositeFSForTest creates a compositeFS for testing purposes.
func ReadThemeStyles ¶ added in v0.7.0
ReadThemeStyles reads base.css and style.css from the resolved static filesystem (theme overrides first, embedded defaults as fallback). The returned CSS is injected into AI text generation so generated HTML reuses the site's design tokens and component classes instead of inventing off-brand styles. A missing file yields an empty string for that slot — callers handle the empty case gracefully.
func ResolveFSForTest ¶
ResolveFSForTest exposes resolveFS for testing purposes.
func StaticFiles ¶
StaticFiles returns an http.Handler that serves the content site's static assets (CSS, JS). When a non-nil Theme with a non-empty Dir is provided, files on disk in that directory are served first, falling back to the embedded defaults for any file not present in the theme directory.
Types ¶
type AuthPageData ¶
type AuthPageData struct {
LayoutData
}
type AuthorData ¶
type AuthorData struct {
LayoutData
AuthorName string
Username string
AuthorAvatarURL string
Posts []PostItem
CustomFieldsFormatted []FormattedField
PaginationData
}
type ContentData ¶
type ContentData struct {
LayoutData
Slug string
Body template.HTML
Tags []string
Author string
Username string
AuthorAvatarURL string
CreatedAt time.Time
AllowComments bool
CustomFields map[string]any
CustomFieldsFormatted []FormattedField
Related []PostItem
Comments []CommentItem
PostType string
}
type FormattedField ¶
type HomeSection ¶ added in v0.5.0
type HomeSection struct {
PostTypeSlug string
Title string
Description string
URL string
Posts []PostItem
}
HomeSection is a per-post-type grouping rendered on the homepage. It is only populated when [[homepage_section]] blocks are configured in config.toml; an empty slice means the theme should fall back to the flat .Posts list.
type IndexData ¶
type IndexData struct {
LayoutData
Posts []PostItem
Tags []string
Sections []HomeSection
PaginationData
}
type LanguageLink ¶
type LayoutData ¶
type LayoutData struct {
Title string
Description string
OGTitle string
OGDesc string
OGImage string
PageTitle string
CurrentPath string
Lang string
LanguageLinks []LanguageLink
SiteConfig SiteConfig
}
type NavigationItem ¶
type NavigationItem struct {
}
type NotFoundData ¶
type NotFoundData struct {
LayoutData
}
type PaginationData ¶ added in v0.5.0
type PaginationData struct {
CurrentPage int
HasPrev bool
HasNext bool
PrevURL string
NextURL string
}
PaginationData carries prev/next state for paginated public listings. It is embedded in IndexData, AuthorData, and TagData so templates reach the fields directly (e.g. {{.NextURL}}). HasNext is derived from the fetch-limit+1 trick, so no COUNT query is required.
type ResetPasswordData ¶
type ResetPasswordData struct {
LayoutData
}
type SiteConfig ¶ added in v0.5.0
SiteConfig carries the site-wide identity (name + optional logo) read from the optional [site_config] block in config.toml. It is the same on every page, so it lives on LayoutData rather than per-page data. Name is always populated (the handler defaults it to the application name); Logo is empty unless the operator configures one, in which case themes render an <img> (using Name as the alt text) instead of the name as text.
type TagData ¶
type TagData struct {
LayoutData
TagName string
Posts []PostItem
PaginationData
}
type Templates ¶
type Templates struct {
// contains filtered or unexported fields
}
func NewTemplates ¶
func (*Templates) RenderAuthor ¶
func (t *Templates) RenderAuthor(w http.ResponseWriter, data AuthorData) error
func (*Templates) RenderAuthorToString ¶ added in v0.8.0
func (t *Templates) RenderAuthorToString(data AuthorData) (string, error)
func (*Templates) RenderContent ¶
func (t *Templates) RenderContent(w http.ResponseWriter, data ContentData) error
func (*Templates) RenderContentToString ¶ added in v0.8.0
func (t *Templates) RenderContentToString(data ContentData) (string, error)
func (*Templates) RenderForgotPassword ¶
func (t *Templates) RenderForgotPassword(w http.ResponseWriter, data AuthPageData) error
func (*Templates) RenderHome ¶ added in v0.6.0
func (t *Templates) RenderHome(w http.ResponseWriter, data IndexData) error
func (*Templates) RenderHomeToString ¶ added in v0.8.0
func (*Templates) RenderIndex ¶
func (t *Templates) RenderIndex(w http.ResponseWriter, data IndexData) error
func (*Templates) RenderIndexToString ¶ added in v0.8.0
func (*Templates) RenderLogin ¶
func (t *Templates) RenderLogin(w http.ResponseWriter, data AuthPageData) error
func (*Templates) RenderLoginToString ¶ added in v0.8.0
func (t *Templates) RenderLoginToString(data AuthPageData) (string, error)
func (*Templates) RenderNotFound ¶
func (t *Templates) RenderNotFound(w http.ResponseWriter, data NotFoundData) error
func (*Templates) RenderNotFoundToString ¶ added in v0.8.0
func (t *Templates) RenderNotFoundToString(data NotFoundData) (string, error)
func (*Templates) RenderRegister ¶
func (t *Templates) RenderRegister(w http.ResponseWriter, data AuthPageData) error
func (*Templates) RenderRegisterToString ¶ added in v0.8.0
func (t *Templates) RenderRegisterToString(data AuthPageData) (string, error)
func (*Templates) RenderResetPassword ¶
func (t *Templates) RenderResetPassword(w http.ResponseWriter, data ResetPasswordData) error
func (*Templates) RenderTag ¶
func (t *Templates) RenderTag(w http.ResponseWriter, data TagData) error
func (*Templates) RenderTagToString ¶ added in v0.8.0
func (*Templates) RenderVerifyEmail ¶
func (t *Templates) RenderVerifyEmail(w http.ResponseWriter, data VerifyEmailData) error
type Theme ¶
type Theme struct {
Dir string
}
Theme holds the path to a custom theme directory on disk. When Dir is empty, embedded defaults are used.
type VerifyEmailData ¶
type VerifyEmailData struct {
LayoutData
}