Documentation
¶
Index ¶
- type Article
- type BuildConfig
- type BuildManifest
- type ChangeSet
- type Config
- type DependencyGraph
- type DevServer
- type FileWatcher
- type FrontMatter
- type I18nConfig
- type LocaleRef
- type Node
- type NodeType
- type OGPConfig
- type OutputFile
- type Pagination
- type ProcessedArticle
- type Site
- type SiteConfig
- type SyntaxHighlightConfig
- type Taxonomy
- type TaxonomyRegistry
- type ThemeConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Article ¶
type Article struct {
FrontMatter FrontMatter
RawContent string
FilePath string
LastModified time.Time
}
Article is the raw data parsed from a Markdown file.
type BuildConfig ¶
type BuildConfig struct {
ContentDir string `yaml:"content_dir"`
OutputDir string `yaml:"output_dir"`
AssetsDir string `yaml:"assets_dir"`
ExcludeFiles []string `yaml:"exclude_files"`
Parallelism int `yaml:"parallelism"`
PerPage int `yaml:"per_page"`
}
BuildConfig holds build-time directory and parallelism settings.
type BuildManifest ¶
type BuildManifest struct {
Version string `json:"version"`
BuildTime time.Time `json:"build_time"`
LastCommit string `json:"last_commit"`
FileHashes map[string]string `json:"file_hashes"`
Dependencies map[string][]string `json:"dependencies"`
OutputFiles []OutputFile `json:"output_files"`
}
BuildManifest is the build history persisted to .gohan/cache/manifest.json.
type Config ¶
type Config struct {
Site SiteConfig `yaml:"site"`
Build BuildConfig `yaml:"build"`
Theme ThemeConfig `yaml:"theme"`
SyntaxHighlight SyntaxHighlightConfig `yaml:"syntax_highlight"`
OGP OGPConfig `yaml:"ogp"`
Plugins map[string]interface{} `yaml:"plugins"`
I18n I18nConfig `yaml:"i18n"`
}
Config is the top-level structure of config.yaml.
type DependencyGraph ¶
DependencyGraph is a directed graph of content dependencies.
type DevServer ¶
type DevServer struct {
Host string
Port int
OutDir string
Watcher FileWatcher
}
DevServer is the local HTTP development server configuration.
type FileWatcher ¶
FileWatcher is the interface for watching file system changes.
type FrontMatter ¶
type FrontMatter struct {
Title string `yaml:"title"`
Date time.Time `yaml:"date"`
Draft bool `yaml:"draft"`
Tags []string `yaml:"tags"`
Categories []string `yaml:"categories"`
Description string `yaml:"description"`
Author string `yaml:"author"`
Slug string `yaml:"slug"`
Template string `yaml:"template"`
// TranslationKey links this article to its translations in other locales.
// Articles sharing the same key are treated as translations of each other,
// enabling language-switcher links via ProcessedArticle.Translations.
TranslationKey string `yaml:"translation_key"`
// Extra captures any front-matter keys not listed above.
// Plugins read their configuration from this field.
Extra map[string]interface{} `yaml:",inline"`
}
FrontMatter holds the YAML metadata from the top of a Markdown file.
type I18nConfig ¶
type I18nConfig struct {
// Locales is the ordered list of locale codes present under the content
// directory (e.g. ["en", "ja"]). When empty, i18n is disabled and gohan
// behaves as a single-language site with no URL changes.
Locales []string `yaml:"locales"`
// DefaultLocale is the locale code served at the root URL (without a
// language prefix). Defaults to Site.Language when Locales is non-empty.
// Example: if DefaultLocale is "en", /posts/hello/ is English and
// /ja/posts/hello/ is Japanese.
DefaultLocale string `yaml:"default_locale"`
}
I18nConfig holds multi-language content configuration.
type LocaleRef ¶
LocaleRef holds a locale code and the canonical URL for a translated variant of an article. Used to generate language-switcher links in templates.
type Node ¶
type Node struct {
Path string
Type NodeType
Dependencies []string
Dependents []string
LastModified time.Time
}
Node is a vertex in the dependency graph.
type OGPConfig ¶
type OGPConfig struct {
Enabled bool `yaml:"enabled"`
BackgroundColor string `yaml:"background_color"`
TextColor string `yaml:"text_color"`
FontFile string `yaml:"font_file"`
LogoFile string `yaml:"logo_file"` // empty means no logo
Width int `yaml:"width"`
Height int `yaml:"height"`
}
OGPConfig holds settings for build-time OGP image generation.
type OutputFile ¶
type OutputFile struct {
Path string `json:"path"`
Hash string `json:"hash"`
Size int64 `json:"size"`
LastModified time.Time `json:"last_modified"`
ContentType string `json:"content_type"`
}
OutputFile records metadata for a single generated file.
type Pagination ¶
type Pagination struct {
CurrentPage int
TotalPages int
PerPage int
TotalItems int
PrevURL string // empty string if no previous page
NextURL string // empty string if no next page
}
Pagination holds computed paging metadata for listing pages.
type ProcessedArticle ¶
type ProcessedArticle struct {
Article
HTMLContent template.HTML
Summary string
OutputPath string
// ContentPath is the content-dir-relative path to the source Markdown file
// (e.g. "posts/hello-world.md"). Used to generate GitHub edit/view links.
ContentPath string
// Locale is the locale code detected from the content path (e.g. "en", "ja").
// Empty when i18n is not configured.
Locale string
// URL is the canonical URL path for this article (e.g. "/posts/hello/" or
// "/ja/posts/hello/"). Empty when i18n is not configured.
URL string
// Translations lists translated variants of this article, keyed by locale.
// Populated by BuildTranslationMap after article processing.
Translations []LocaleRef
// PluginData holds per-article data injected by enabled plugins.
// Access in templates: {{index .PluginData "amazon_books"}}
PluginData map[string]interface{}
}
ProcessedArticle holds derived data generated by the renderer.
type Site ¶
type Site struct {
Config Config
Articles []*ProcessedArticle
Tags []Taxonomy
Categories []Taxonomy
Pagination *Pagination // nil when pagination is disabled or not a listing page
}
Site holds the full rendering context passed to templates.
type SiteConfig ¶
type SiteConfig struct {
Title string `yaml:"title"`
Description string `yaml:"description"`
BaseURL string `yaml:"base_url"`
Language string `yaml:"language"`
// GitHubRepo is the base URL of the GitHub repository that holds the site
// source (e.g. "https://github.com/owner/repo"). When set, templates can
// render an "Edit this page" link using .ContentPath.
GitHubRepo string `yaml:"github_repo"`
// GitHubBranch is the branch used to build the edit URL. Defaults to "main".
GitHubBranch string `yaml:"github_branch"`
}
SiteConfig holds site-wide metadata.
type SyntaxHighlightConfig ¶
type SyntaxHighlightConfig struct {
// Theme is a chroma style name (e.g. "github", "monokai", "dracula").
Theme string `yaml:"theme"`
// LineNumbers enables line number display when true.
LineNumbers bool `yaml:"line_numbers"`
}
SyntaxHighlightConfig holds settings for code-block syntax highlighting.
type TaxonomyRegistry ¶
type TaxonomyRegistry struct {
Tags []Taxonomy `yaml:"tags"`
Categories []Taxonomy `yaml:"categories"`
}
TaxonomyRegistry holds the master lists loaded from taxonomy YAML files.