Skip to content

Commit

Permalink
Taking configs and params and not making it iife
Browse files Browse the repository at this point in the history
  • Loading branch information
bandana147 committed Jul 23, 2024
1 parent 158016d commit 948ce73
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions libs/navigation/footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,25 @@ const blockConfig = {
appendType: 'appendChild',
};

async function loadBlock() {
const { fedsGlobalConfig = {} } = window;
const miloLibs = fedsGlobalConfig.miloLibs || 'https://www.adobe.com';
export default async function loadBlock(configs = {}) {
let miloLibs = configs.miloLibs || 'https://www.adobe.com';
const branch = new URLSearchParams(window.location.search).get('branch');
if (branch) {
miloLibs = `https://${branch}--milo--adobecom.hlx.page`
}
const { locale, contentRoot} = configs;

// 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: locales } = await import(`${miloLibs}/libs/utils/locales.js`);
const clientConfig = {
contentRoot,
origin: miloLibs,
contentRoot: fedsGlobalConfig.contentRoot,
miloLibs: `${miloLibs}/libs`,
pathname: `/${fedsGlobalConfig.locale || ''}`,
locales: fedsGlobalConfig.locales || locales,
pathname: `/${locale || ''}`,
locales: configs.locales || locales,
};

bootstrapBlock(clientConfig, blockConfig);
}

loadBlock();

0 comments on commit 948ce73

Please sign in to comment.