Skip to content
Snippets Groups Projects
Commit 163bb8a5 authored by Julien MARGAIL's avatar Julien MARGAIL
Browse files

fix menu isActive for type=none or empty url

parent 6293ea66
No related branches found
No related tags found
No related merge requests found
......@@ -84,16 +84,32 @@ const Menu = (props: Imenu) => {
const goto = (item) => {
if (!item) return ""
// Type = none | page | url
if (item?.type === "none") return ""
if (item?.type === "page") {
const slug = item?.page?.slug || ""
if (slug.at(0) === "/") return slug
return "/" + slug
}
return item?.url || ""
}
// Check if Item has a valid link
const isValid = (item) => {
if (!item) return false
// Type = none | page | url
if (item?.type === "none") return false
if (item?.type === "page" && (item?.page?.slug || "") === "")
return false
if (item?.type === "url" && (item?.url || "") === "") return false
return true
}
const isActive = (item) => {
if (!isValid(item)) return false
// Get last part of item url without '/'
const url =
goto(item)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment