// Package layout provides the shared server-rendered web UI chrome (base // layout, navbar, sidebar, footer) used by every Yetano/Yak/Yamase // ops-tool admin dashboard: yasta, yasl, yaiam, yakwui, and yamase-web. // // Consumers embed PageHeader in their own per-page data struct and use // NewRenderer to parse the shared layout templates together with their // own page-specific templates. Page-content styling (cards, tables, // badges, forms, ...) stays each project's own concern; only the chrome // that base/navbar/sidebar/footer actually render is shared here. package layout import ( "embed" "fmt" "html/template" "io" "io/fs" "net/http" ) //go:embed templates/layout var templateFS embed.FS //go:embed static var staticFS embed.FS // LayoutGlob is the glob NewRenderer uses to pull in the shared // base/navbar/sidebar/footer templates. const LayoutGlob = "templates/layout/*.tmpl" // NavItem is one sidebar entry. type NavItem struct { ID string // matches PageHeader.ActiveNav to mark this item active Label string Href string // BasePath-relative, e.g. "/tasks" } // PageHeader holds the fields every page's own data struct should embed // so the shared base/navbar/sidebar/footer templates can render // regardless of which project or page is being rendered. Zero-valued // fields simply render nothing (e.g. Username == "" hides the // username/logout group). type PageHeader struct { Title string Name string // lowercase product name, e.g. "yasta"; used in