package components
import "github.com/tigorlazuardi/redmage/views"
import "strings"
import "github.com/tigorlazuardi/redmage/views/utils"
templ Navigation(c *views.Context) {
}
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) {
@navLogo()
Redmage
}
templ navList(c *views.Context) {
@createLink(c, "/", "Home")
@createLink(c, "/config", "Config")
@createLink(c, "/devices", "Devices")
@createLink(c, "/subreddits", "Subreddits")
@createLink(c, "/history", "History")
@createLink(c, "/about", "About")
}
templ createLink(c *views.Context, path string, text string) {
{ 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
}