package components import "github.com/tigorlazuardi/redmage/views" import "strings" import "github.com/tigorlazuardi/redmage/views/utils" import "strconv" templ Navigation(c *views.Context) {
{ children... }
} func cx(m map[string]bool) string { var res string for k, v := range m { if v { res += k + " " } } return res } func classForNavItem(c *views.Context, prefix string) string { classNames := map[string]bool{} if prefix == "/" && c.Request.URL.Path == "/" { classNames["font-bold"] = true return cx(classNames) } else if strings.HasPrefix(c.Request.URL.Path, prefix) && prefix != "/" { classNames["font-bold"] = true } return cx(classNames) } templ navLogo() { } templ Navbar(c *views.Context) { } templ navList(c *views.Context) { @createLink(c, "/", "Home", true) @createLink(c, "/config", "Config", false) @createLink(c, "/devices", "Devices", true) @createLink(c, "/subreddits", "Subreddits", true) @createLink(c, "/schedules", "Schedules", true)
@createLink(c, "/about", "About", true)
} templ createLink(c *views.Context, path string, text string, boost bool) { { text } } func isCurrentPage(c *views.Context, path string) bool { if path == "/" && c.Request.URL.Path == "/" { return true } else if strings.HasPrefix(c.Request.URL.Path, path) && path != "/" { return true } return false }