Simplify getting the active path
This commit is contained in:
@@ -1,7 +1,5 @@
|
|||||||
package ersteller_lib
|
package ersteller_lib
|
||||||
|
|
||||||
import "strings"
|
|
||||||
|
|
||||||
type Language string
|
type Language string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -95,9 +93,6 @@ func (a ActivePath) GetPath(language Language) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a ActivePath) IsActive(c HtmxContext) bool {
|
func (a ActivePath) IsActive(c HtmxContext) bool {
|
||||||
pathWithLang := a.GetPath(c.GetLanguage())
|
contextActivePath := c.GetActivePath()
|
||||||
if pathWithLang == c.GetLanguage().GetPath()+"/" {
|
return contextActivePath != nil && contextActivePath.From(c) == a.From(c)
|
||||||
return pathWithLang == c.GetPath()
|
|
||||||
}
|
|
||||||
return strings.HasPrefix(c.GetPath(), pathWithLang)
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user