Skip to content

Commit

Permalink
Fix to accomodate gnav component from same script
Browse files Browse the repository at this point in the history
  • Loading branch information
Snehal Sonawane authored and bandana147 committed Jul 23, 2024
1 parent 56c6c2a commit 291d2e7
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions libs/navigation/footer.js → libs/navigation/navigation.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
const blockConfig = {
name: 'global-footer',
targetEl: 'footer',
appendType: 'appendChild',
footer: {
name: 'global-footer',
targetEl: 'footer',
appendType: 'appendChild',
},
};

const envMap = {
Expand All @@ -11,21 +13,22 @@ const envMap = {
};

export default async function loadBlock(configs = {}) {
const { locale, authoringPath, env = 'prod', privacyId, privacyLoadDelay = 3000 } = configs;
const { footer, locale, env = 'prod' } = configs;
const branch = new URLSearchParams(window.location.search).get('navbranch');
const miloLibs = branch ? `https://${branch}--milo--adobecom.hlx.page` : envMap[env];

// Relative path can't be used, as the script will run on consumer's app
const { default: bootstrapBlock } = await import(`${miloLibs}/libs/navigation/bootstrapper.js`);
const { default: bootstrapper } = await import(`${miloLibs}/libs/navigation/bootstrapper.js`);
const { default: locales } = await import(`${miloLibs}/libs/utils/locales.js`);
const clientConfig = {
privacyId,
contentRoot: authoringPath,
origin: miloLibs,
miloLibs: `${miloLibs}/libs`,
pathname: `/${locale || ''}`,
locales: configs.locales || locales,
};
blockConfig.delay = privacyLoadDelay;
bootstrapBlock(clientConfig, blockConfig);
if (footer) {
const { footer: { authoringPath, privacyId, privacyLoadDelay = 3000 } } = configs;
blockConfig.delay = privacyLoadDelay;
bootstrapper({ ...clientConfig, contentRoot: authoringPath, privacyId }, blockConfig.footer);
}
}

0 comments on commit 291d2e7

Please sign in to comment.