template

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 16, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCompositeFSForTest

func NewCompositeFSForTest(primary, secondary fs.FS) fs.FS

NewCompositeFSForTest creates a compositeFS for testing purposes.

func ResolveFSForTest

func ResolveFSForTest(theme *Theme, embedded fs.FS, subPath string) fs.FS

ResolveFSForTest exposes resolveFS for testing purposes.

func StaticFiles

func StaticFiles(theme *Theme) http.Handler

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
}

type CommentItem

type CommentItem struct {
	Author    string
	Text      string
	CreatedAt string
}

type ContentData

type ContentData struct {
	LayoutData
	Slug                  string
	Body                  template.HTML
	Tags                  []string
	Author                string
	Username              string
	AuthorAvatarURL       string
	CreatedAt             string
	AllowComments         bool
	CustomFields          map[string]any
	CustomFieldsFormatted []FormattedField
	Comments              []CommentItem
}

type FormattedField

type FormattedField struct {
	Label string
	Value string
}

type IndexData

type IndexData struct {
	LayoutData
	Posts []PostItem
	Tags  []string
}
type LanguageLink struct {
	Code string
	Name string
	URL  string
}

type LayoutData

type LayoutData struct {
	Title           string
	Description     string
	OGTitle         string
	OGDesc          string
	OGImage         string
	PageTitle       string
	NavigationItems []NavigationItem
	CurrentPath     string
	Lang            string
	LanguageLinks   []LanguageLink
}
type NavigationItem struct {
	Title    string
	URL      string
	IsActive bool
}

type NotFoundData

type NotFoundData struct {
	LayoutData
}

type PostItem

type PostItem struct {
	Slug            string
	Title           string
	MetaDescription string
	ImageURL        string
	ImageSrcset     string
	ImageSizes      string
	Author          string
	Username        string
	AuthorAvatarURL string
	CreatedAt       string
}

type ResetPasswordData

type ResetPasswordData struct {
	LayoutData
}

type TagData

type TagData struct {
	LayoutData
	TagName string
	Posts   []PostItem
}

type Templates

type Templates struct {
	// contains filtered or unexported fields
}

func NewTemplates

func NewTemplates(theme *Theme, catalog *i18n.Catalog) (*Templates, error)

func (*Templates) RenderAuthor

func (t *Templates) RenderAuthor(w http.ResponseWriter, data AuthorData) error

func (*Templates) RenderContent

func (t *Templates) RenderContent(w http.ResponseWriter, data ContentData) error

func (*Templates) RenderForgotPassword

func (t *Templates) RenderForgotPassword(w http.ResponseWriter, data AuthPageData) error

func (*Templates) RenderIndex

func (t *Templates) RenderIndex(w http.ResponseWriter, data IndexData) error

func (*Templates) RenderLogin

func (t *Templates) RenderLogin(w http.ResponseWriter, data AuthPageData) error

func (*Templates) RenderNotFound

func (t *Templates) RenderNotFound(w http.ResponseWriter, data NotFoundData) error

func (*Templates) RenderRegister

func (t *Templates) RenderRegister(w http.ResponseWriter, data AuthPageData) 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) 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
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL