Documentation
¶
Overview ¶
Package themekit is the shared catalog theme contract: validation helpers for ship-with and custom themes. The theme doctor CLI and token helpers can grow here without pulling theme markup into internal/.
Catalog themes under themes/ must pass ValidateDir with CatalogOptions. Child themes that inherit from default may omit files the parent already provides; ValidateDir walks the parent chain.
Index ¶
- Constants
- Variables
- func AnyFailed(results []Result) bool
- func AssetPath(slug, rel string) string
- func DataThemeSelector(slug string) string
- func ExtractTKeys(dir string) ([]string, error)
- func FormatResult(res Result) string
- func MergeLang(chainDirs []string, locale string) (map[string]string, error)
- func MissingLangKeys(used []string, catalog map[string]string) []string
- func SettingKey(slug, field string) string
- type Issue
- type Options
- type Result
Constants ¶
const CoreStylesheetPath = "/static/site/core.css"
CoreStylesheetPath is the core site stylesheet GoRun serves from the binary (theme.CoreCSSPath); {{sections .}} links it with a content hash.
const PlatformLangPrefix = "core."
PlatformLangPrefix marks keys that resolve from core/module catalogs (e.g. {{t "core.app.name"}}), not theme lang files.
Variables ¶
var CatalogSlugs = []string{"default", "business", "magazine", "portfolio", "docs"}
CatalogSlugs are the five themes GoRun ships in themes/.
var IdentityTokens = []string{
"--accent",
"--gp-accent",
"--green",
"--bg",
"--ink",
"--on-accent",
"--gp-on-accent",
"--font",
"--font-ui",
"--font-heading",
"--radius",
}
IdentityTokens are CSS custom properties site identity can drive. Catalog themes declare defaults under DataThemeSelector(slug).
var RequiredLocales = []string{"en", "ar"}
RequiredLocales are lang/<locale>.json files every catalog theme must own (parent merge is not enough for the ship-with quality bar).
var RequiredSupports = []string{"rtl", "identity"}
RequiredSupports must appear in theme.json "supports".
var RequiredTemplates = []string{
"index.html",
"page.html",
"single.html",
"archive.html",
"taxonomy.html",
"search.html",
"404.html",
"500.html",
"page-builder.html",
"page-contact.html",
"form-result.html",
}
RequiredTemplates must resolve for a catalog theme (own file or inherited).
Functions ¶
func AssetPath ¶
AssetPath builds the public URL path for a theme asset (no cache buster). Templates use {{asset "…"}} at render time; this helper is for tooling.
func DataThemeSelector ¶
DataThemeSelector returns the zero-specificity selector catalog themes use for token defaults.
func ExtractTKeys ¶
ExtractTKeys returns unique {{t "…"}} keys referenced in HTML under dir (templates/, parts/, components/).
func FormatResult ¶
FormatResult writes a human-readable doctor line for one Result.
func MissingLangKeys ¶
MissingLangKeys returns used keys absent from catalog, skipping platform keys.
func SettingKey ¶
SettingKey returns the settings store key for a theme setting field.
Types ¶
type Issue ¶
type Issue struct {
Path string `json:"path,omitempty"`
Code string `json:"code"`
Message string `json:"message"`
}
Issue is one contract failure.
func LangKeyWarnings ¶
LangKeyWarnings scans the theme's own HTML for {{t}} keys missing from the merged en (then ar) catalogs along the parent chain. These are soft checks for `gorun theme doctor` and do not affect ValidateDir / catalog CI.
type Options ¶
type Options struct {
// RequireLocales requires lang/<locale>.json on the theme itself.
RequireLocales []string
// RequireSupports lists theme.json supports values.
RequireSupports []string
// RequireTemplates lists templates that must resolve via inheritance.
RequireTemplates []string
// RequireScreenshot requires screenshot.png at the theme root.
RequireScreenshot bool
// RequireHome requires front-page.html or home.html (resolved).
RequireHome bool
// ForbidScriptHosts fails when theme HTML/CSS references these substrings
// (public CSP: no third-party script CDNs). Empty skips the check.
ForbidScriptHosts []string
// RequireTokenSelector requires the theme's primary stylesheet to declare
// tokens under :where(html[data-theme="<slug>"]).
RequireTokenSelector bool
}
Options configure ValidateDir. CatalogOptions is the ship-with bar.
func CatalogOptions ¶
func CatalogOptions() Options
CatalogOptions is the shared ship-with contract.
func OptionsForSlug ¶
OptionsForSlug returns CatalogOptions for ship-with themes and a lighter activation-oriented check for custom themes (index.html must resolve).
type Result ¶
type Result struct {
Slug string `json:"slug"`
OK bool `json:"ok"`
Issues []Issue `json:"issues,omitempty"`
}
Result is the outcome of ValidateDir.
func DoctorRoots ¶
DoctorRoots validates every theme.json directory under roots (first root wins per slug). Catalog slugs use CatalogOptions; others use OptionsForSlug.
func DoctorTheme ¶
DoctorTheme validates one theme directory using OptionsForSlug(slug).
func ValidateCatalogRoot ¶
ValidateCatalogRoot validates every CatalogSlug under root.