Add ActivePath as NavItems
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package ersteller_lib
|
||||
|
||||
import "strings"
|
||||
|
||||
type Language string
|
||||
|
||||
const (
|
||||
@@ -81,3 +83,12 @@ func NewActivePath(path string, langMap map[Language]string) ActivePath {
|
||||
Path: path,
|
||||
}
|
||||
}
|
||||
|
||||
func (a ActivePath) GetPath(language Language) string {
|
||||
return "/" + string(language) + a.Path
|
||||
}
|
||||
|
||||
func (a ActivePath) IsActive(c HtmxContext) bool {
|
||||
pathWithLang := a.GetPath(c.GetLanguage())
|
||||
return strings.HasPrefix(c.GetPath(), pathWithLang)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user