theme

package
v1.6.2 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package theme holds the built-in html/template set (layout, page, dirlist, tree) and static assets (CSS, enhancement JS, vendored mermaid.js), all embedded via go:embed. Customization is three-tiered: CSS variables, appended CSS, template override. Template names are public API — add sparingly.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UIStrings added in v1.1.0

func UIStrings(lang string) map[string]string

UIStrings returns built-in theme UI strings for site.language. Chinese variants use zh; every other language falls back to English.

Types

type Crumb

type Crumb struct {
	Label   string
	Path    string
	Href    string
	Current bool
}

Crumb is one breadcrumb item. Path is the complete repository-relative path ("." for root), while Href is already relative to the current page. Current marks the terminal crumb so templates can render it without a link.

type DirEntry

type DirEntry struct {
	Name       string
	Path       string
	Href       string
	Kind       string
	Size       int64
	LastCommit *source.Commit
	IsDir      bool
}

DirEntry is one child row rendered by the "dirlist" template. Href is already relative to the current directory page.

type PageData

type PageData struct {
	Title, SiteTitle string
	RelRoot          string
	TreePosition     string
	Breadcrumbs      []Crumb
	Tree             *TreeNode
	Kind             string
	KindLabel        string
	Body             template.HTML
	TOC              []render.TOCItem
	MirrorHref       string
	SourceHref       string
	FileSize         int64
	RepoPath         string
	TOCPanel         string
	UI               map[string]string
	LastCommit       *source.Commit
	HasMermaid       bool
	NoIndex          bool
	HidePageTitle    bool
	SearchEnabled    bool
	SnapshotID       string
	HeadExtra        template.HTML
	DirEntries       []DirEntry
	// Lang 为 <html lang> 属性值(site.language),空则省略该属性。
	Lang string
}

type Renderer

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

Renderer owns the parsed template set and static theme resources.

func New

func New(overrideDir, customCSS string, vars map[string]string) (*Renderer, error)

New creates a Renderer from built-in templates plus optional user overrides.

func (*Renderer) Page

func (r *Renderer) Page(w io.Writer, d PageData) error

func (*Renderer) WriteAssets

func (r *Renderer) WriteAssets(outDir string) error

type TreeNode

type TreeNode struct {
	Name     string
	Path     string
	Href     string
	Kind     string
	IsDir    bool
	Current  bool
	Expanded bool
	// SearchEnabled controls the tree-top search entry on the root node.
	SearchEnabled bool
	Children      []*TreeNode
}

TreeNode is the file-tree shape consumed by the "tree" template. Href is already relative to the current page. Directories use Expanded for the current-path ancestors and Current when the directory page itself is active.

Jump to

Keyboard shortcuts

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