Documentation
¶
Index ¶
- Variables
- type AssetResolver
- type BuildContext
- type BuildMetadata
- type BuildMetrics
- type BuildOptions
- type BuildResult
- type Config
- type Dependencies
- type DependencyMetadata
- type Hooks
- type LocaleLookup
- type LocaleSpec
- type NoOpAssetResolver
- type PageData
- type PageRenderingContext
- type RenderDiagnostic
- type RenderedPage
- type Service
- type SiteMetadata
- type TemplateContext
- type TemplateHelpers
- type ThemeContext
- type ThemingConfig
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotImplemented indicates that a generator operation has not been implemented yet. ErrNotImplemented = errors.New("generator: operation not implemented") // ErrServiceDisabled indicates the generator feature is disabled. ErrServiceDisabled = errors.New("generator: service disabled") )
Functions ¶
This section is empty.
Types ¶
type AssetResolver ¶
type AssetResolver interface {
Open(ctx context.Context, theme *themes.Theme, asset string) (io.ReadCloser, error)
ResolvePath(theme *themes.Theme, asset string) (string, error)
}
AssetResolver resolves theme assets for copying into static outputs.
type BuildContext ¶
type BuildContext struct {
GeneratedAt time.Time
DefaultLocale string
Locales []LocaleSpec
Pages []*PageData
MenuAliases map[string]string
Options BuildOptions
}
BuildContext aggregates the localized page data required to execute a static build.
type BuildMetadata ¶
type BuildMetadata struct {
GeneratedAt time.Time
Options BuildOptions
}
BuildMetadata surfaces high level build information to templates.
type BuildMetrics ¶
type BuildMetrics struct {
ContextDuration time.Duration
RenderDuration time.Duration
PersistDuration time.Duration
AssetDuration time.Duration
SitemapDuration time.Duration
RobotsDuration time.Duration
FeedDuration time.Duration
PagesPerSecond float64
AssetsPerSecond float64
SkippedPagesPerSecond float64
}
BuildMetrics captures timing and throughput statistics for a generator run.
type BuildOptions ¶
type BuildOptions struct {
Locales []string
PageIDs []uuid.UUID
DryRun bool
Force bool
AssetsOnly bool
}
BuildOptions narrows the scope of a generator run.
type BuildResult ¶
type BuildResult struct {
PagesBuilt int
PagesSkipped int
AssetsBuilt int
AssetsSkipped int
FeedsBuilt int
Locales []string
Duration time.Duration
Rendered []RenderedPage
Diagnostics []RenderDiagnostic
Errors []error
DryRun bool
Metrics BuildMetrics
}
BuildResult reports aggregated build metadata.
type Config ¶
type Config struct {
OutputDir string
BaseURL string
CleanBuild bool
Incremental bool
CopyAssets bool
GenerateSitemap bool
GenerateRobots bool
GenerateFeeds bool
Workers int
DefaultLocale string
Locales []string
Menus map[string]string
RenderTimeout time.Duration
AssetCopyTimeout time.Duration
Theming ThemingConfig
}
Config captures runtime behaviour toggles for the generator.
type Dependencies ¶
type Dependencies struct {
Pages pages.Service
Content content.Service
Blocks blocks.Service
Widgets widgets.Service
Menus menus.Service
Themes themes.Service
I18N i18n.Service
Renderer interfaces.TemplateRenderer
Storage interfaces.StorageProvider
Locales LocaleLookup
Assets AssetResolver
Hooks Hooks
Logger interfaces.Logger
Shortcodes interfaces.ShortcodeService
}
Dependencies lists the services required by the generator.
type DependencyMetadata ¶
DependencyMetadata tracks hashes and timestamps for incremental builds.
type Hooks ¶
type Hooks struct {
BeforeBuild func(context.Context, BuildOptions) error
AfterBuild func(context.Context, BuildOptions, *BuildResult) error
AfterPage func(context.Context, RenderedPage) error
BeforeClean func(context.Context, string) error
AfterClean func(context.Context, string) error
}
Hooks expose lifecycle callbacks for build operations.
type LocaleLookup ¶
type LocaleLookup interface {
GetByCode(ctx context.Context, code string) (*content.Locale, error)
}
LocaleLookup resolves locales from configured repositories.
type LocaleSpec ¶
LocaleSpec captures resolved locale information for a build.
type NoOpAssetResolver ¶
type NoOpAssetResolver struct{}
NoOpAssetResolver skips asset resolution.
func (NoOpAssetResolver) Open ¶
func (NoOpAssetResolver) Open(context.Context, *themes.Theme, string) (io.ReadCloser, error)
func (NoOpAssetResolver) ResolvePath ¶
type PageData ¶
type PageData struct {
Page *pages.Page
Content *content.Content
Locale LocaleSpec
Translation *pages.PageTranslation
ContentTranslation *content.ContentTranslation
Blocks []*blocks.Instance
Widgets map[string][]*widgets.ResolvedWidget
Menus map[string][]menus.NavigationNode
Template *themes.Template
Theme *themes.Theme
ThemeSelection *gotheme.Selection
Metadata DependencyMetadata
}
PageData encapsulates resolved dependencies for a page/locale combination.
type PageRenderingContext ¶
type PageRenderingContext struct {
Page *pages.Page
Content *content.Content
Translation *pages.PageTranslation
ContentTranslation *content.ContentTranslation
Blocks []*blocks.Instance
Widgets map[string][]*widgets.ResolvedWidget
Menus map[string][]menus.NavigationNode
Template *themes.Template
Theme *themes.Theme
Locale LocaleSpec
Metadata DependencyMetadata
}
PageRenderingContext contains the resolved dependencies for a single page/locale combination.
type RenderDiagnostic ¶
type RenderDiagnostic struct {
PageID uuid.UUID
Locale string
Route string
Template string
Duration time.Duration
Skipped bool
Err error
}
RenderDiagnostic records rendering timing and errors for individual pages.
type RenderedPage ¶
type RenderedPage struct {
PageID uuid.UUID
Locale string
Route string
Output string
Template string
HTML string
Metadata DependencyMetadata
Duration time.Duration
Checksum string
}
RenderedPage captures the rendered HTML output for a page.
type Service ¶
type Service interface {
Build(ctx context.Context, opts BuildOptions) (*BuildResult, error)
BuildPage(ctx context.Context, pageID uuid.UUID, locale string) error
BuildAssets(ctx context.Context) error
BuildSitemap(ctx context.Context) error
Clean(ctx context.Context) error
}
Service describes the static site generator contract.
func NewDisabledService ¶
func NewDisabledService() Service
NewDisabledService returns a Service that fails all operations with ErrServiceDisabled.
func NewService ¶
func NewService(cfg Config, deps Dependencies) Service
NewService wires a generator implementation with the provided configuration and dependencies.
type SiteMetadata ¶
type SiteMetadata struct {
BaseURL string
DefaultLocale string
Locales []LocaleSpec
MenuAliases map[string]string
Metadata map[string]any
}
SiteMetadata exposes locale-aware information required by templates.
type TemplateContext ¶
type TemplateContext struct {
Site SiteMetadata
Page PageRenderingContext
Build BuildMetadata
Theme ThemeContext
Helpers TemplateHelpers
}
TemplateContext captures the data contract passed to TemplateRenderer implementations.
type TemplateHelpers ¶
type TemplateHelpers struct {
// contains filtered or unexported fields
}
TemplateHelpers exposes convenience helpers for template authors.
func (TemplateHelpers) BaseURL ¶
func (h TemplateHelpers) BaseURL() string
BaseURL returns the configured site base URL.
func (TemplateHelpers) IsDefaultLocale ¶
func (h TemplateHelpers) IsDefaultLocale() bool
IsDefaultLocale reports whether the current locale matches the configured default.
func (TemplateHelpers) IsLocale ¶
func (h TemplateHelpers) IsLocale(code string) bool
IsLocale reports whether the provided locale code matches the active locale.
func (TemplateHelpers) Locale ¶
func (h TemplateHelpers) Locale() string
Locale returns the active locale code.
func (TemplateHelpers) LocalePrefix ¶
func (h TemplateHelpers) LocalePrefix() string
LocalePrefix returns the locale aware prefix for paths.
func (TemplateHelpers) WithBaseURL ¶
func (h TemplateHelpers) WithBaseURL(path string) string
WithBaseURL prefixes the provided path with the configured base URL.
type ThemeContext ¶ added in v0.4.0
type ThemeContext struct {
Name string
Variant string
Tokens map[string]string
CSSVars map[string]string
Partials map[string]string
AssetURL func(string) string
Template func(string, string) string
Selection *gotheme.Selection
}
ThemeContext surfaces go-theme selection data to templates.