From 65eb3cc6b198a5003d3432116168d9da72c35740 Mon Sep 17 00:00:00 2001 From: Bandana Laishram Date: Thu, 3 Sep 2026 15:33:37 +0530 Subject: [PATCH 1/2] Adding resolveFragmentHref to support fragment mep --- .../global-navigation/global-navigation.js | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/libs/c2/blocks/global-navigation/global-navigation.js b/libs/c2/blocks/global-navigation/global-navigation.js index 4447a1c7b43..543c1b9c41a 100644 --- a/libs/c2/blocks/global-navigation/global-navigation.js +++ b/libs/c2/blocks/global-navigation/global-navigation.js @@ -7,6 +7,7 @@ import { convertStageLinks, lingoActive, getLingoRegion, + getFederatedUrl, } from '../../../utils/utils.js'; const DEFAULT_FEDERAL_URL = 'https://main--federal--adobecom.aem.page'; @@ -82,6 +83,30 @@ export default async function init(el) { return handleCommands(cs, root, true, true); }; + // Mirrors fragment.js's mep.fragments lookup + handleFragmentCommand: swaps + // a nested `#_inline` product-card (or other) fragment href for whatever + // MEP's page-wide fragment-replace manifest points it at. `#_inline` is + // stripped before matching federal hrefs against the map, since that's how + // the map's keys were normalized too. + const resolveFragmentHref = async (href) => { + // The fetched fragment's authored href still points at federal's own + // authoring domain (e.g. main--federal--adobecom.aem.page) — federate it + // first so the lookup key matches config.mep.fragments, whose keys went + // through the same getFederatedUrl call inside normalizePath. + const isFederalHref = href.includes('/federal/'); + const path = isFederalHref + ? getFederatedUrl(href).replace('#_inline', '') + : new URL(href).pathname; + const mepFrag = config.mep?.fragments?.[path] + ?? config.mep?.fragments?.[path.replace(config.locale?.prefix ?? '', '')]; + if (!mepFrag) return href; + const { handleFragmentCommand } = await import('../../../features/personalization/personalization.js'); + const tempAnchor = document.createElement('a'); + tempAnchor.href = href; + const resolved = handleFragmentCommand(mepFrag, tempAnchor); + return resolved ? tempAnchor.href : href; + }; + const { main } = await import(federalGnavUrl); const gnavUrl = new URL(getMetadata('gnav-source') || `${config.locale?.contentRoot ?? window.location.origin}/gnav`); @@ -112,6 +137,7 @@ export default async function init(el) { personalization: { commands: [...commands, ...gnavMepCommands], handleCommands: personalizationHandler, + resolveFragmentHref, }, convertStageLinks: ({ anchors, hostname, href }) => { convertStageLinks({ anchors, config, hostname, href }); From c88309041e67ec3af5e5c230b100dcd2e678122d Mon Sep 17 00:00:00 2001 From: Bandana Laishram Date: Thu, 3 Sep 2026 16:48:54 +0530 Subject: [PATCH 2/2] Removing unwanted comment --- libs/c2/blocks/global-navigation/global-navigation.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/libs/c2/blocks/global-navigation/global-navigation.js b/libs/c2/blocks/global-navigation/global-navigation.js index 543c1b9c41a..7782d246560 100644 --- a/libs/c2/blocks/global-navigation/global-navigation.js +++ b/libs/c2/blocks/global-navigation/global-navigation.js @@ -85,14 +85,8 @@ export default async function init(el) { // Mirrors fragment.js's mep.fragments lookup + handleFragmentCommand: swaps // a nested `#_inline` product-card (or other) fragment href for whatever - // MEP's page-wide fragment-replace manifest points it at. `#_inline` is - // stripped before matching federal hrefs against the map, since that's how - // the map's keys were normalized too. + // MEP's page-wide fragment-replace manifest points it at. const resolveFragmentHref = async (href) => { - // The fetched fragment's authored href still points at federal's own - // authoring domain (e.g. main--federal--adobecom.aem.page) — federate it - // first so the lookup key matches config.mep.fragments, whose keys went - // through the same getFederatedUrl call inside normalizePath. const isFederalHref = href.includes('/federal/'); const path = isFederalHref ? getFederatedUrl(href).replace('#_inline', '')