diff --git a/.env.local.template b/.env.local.template index 9e6a7d39..f189a412 100644 --- a/.env.local.template +++ b/.env.local.template @@ -1,6 +1,9 @@ APP_VERSION=$npm_package_version APP_NAME=$npm_package_name NEXT_PUBLIC_KONTENT_ENVIRONMENT_ID=2cedc519-a547-01ba-dde7-b01e00b909a1 -KONTENT_COLLECTION_CODENAME=ficto_healthtech_surgical +NEXT_PUBLIC_KONTENT_COLLECTION_CODENAME=ficto_healthtech_surgical +# Collection in format : i.e. "ficto_healthtech:ficto-healthtech.vercel.app,ficto_healthtech_imaging:ficto-healthtech-imaging.vercel.app,ficto_healthtech_surgical:ficto-healthtech-surgical.vercel.app +NEXT_PUBLIC_COLLECTION_DOMAINS= KONTENT_PREVIEW_API_KEY= KONTENT_MANAGEMENT_API_KEY= + diff --git a/components/shared/ui/menu.tsx b/components/shared/ui/menu.tsx index 5083cf03..0915d07e 100644 --- a/components/shared/ui/menu.tsx +++ b/components/shared/ui/menu.tsx @@ -5,8 +5,9 @@ import { FC, useState } from "react"; import { mainColorBgClass } from "../../../lib/constants/colors"; import { createItemSmartLink } from "../../../lib/utils/smartLinkUtils"; -import { Block_Navigation } from "../../../models"; +import { Block_Navigation, contentTypes } from "../../../models"; import { useSiteCodename } from "../siteCodenameContext"; +import { externalPreviewUrlsMapping } from "../../../lib/constants/menu"; type Link = Readonly; @@ -29,9 +30,24 @@ const isCurrentNavigationItemActive = (navigation: Block_Navigation, router: Nex const pathWithoutQuerystring = router.asPath.replace(/\?.*/, ''); const pathSegments = pathWithoutQuerystring.split("/"); const topLevelSegment = pathSegments[1]; - return (navigation.elements.pageLink.linkedItems[0]?.elements.url.value === topLevelSegment); + const pageLink = navigation.elements.pageLink.linkedItems[0]; + return (pageLink?.system.codename === contentTypes.page.codename && pageLink?.elements.url.value === topLevelSegment); }; +const resolveLink = (link: Readonly) => { + if (link.elements.externalLink.value) { + return link.elements.externalLink.value; + } + + const pageLink = link.elements.pageLink.linkedItems[0]; + const collectionDomain = externalPreviewUrlsMapping[pageLink?.system.collection ?? ""] || ""; + + if (pageLink?.system.type === contentTypes.web_spotlight_root.codename) { + return collectionDomain; + } + + return collectionDomain + "/" + pageLink?.elements.url.value; +} const MenuList: FC = props => { const router = useRouter(); @@ -59,7 +75,7 @@ const MenuList: FC = props => { {link.elements.label.value} @@ -70,6 +86,7 @@ const MenuList: FC = props => { ); } + const DropdownButton: FC = props => { return (