Skip to content

Commit

Permalink
Merge branch 'stage' into MWPW-155385-personalisation
Browse files Browse the repository at this point in the history
  • Loading branch information
zagi25 committed Aug 13, 2024
2 parents 3d4bc81 + 5d9d1fe commit b8ba74c
Show file tree
Hide file tree
Showing 7 changed files with 8,186 additions and 2,529 deletions.
3 changes: 3 additions & 0 deletions babel.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
presets: [['@babel/preset-env', {targets: {node: 'current'}}]],
};
7 changes: 7 additions & 0 deletions edsdme/scripts/scripts.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { setLibs, redirectLoggedinPartner, updateIMSConfig, preloadResources, getRenewBanner } from './utils.js';
import { applyPagePersonalization } from './personalization.js';
import { setLibs, redirectLoggedinPartner, updateIMSConfig, preloadResources, getRenewBanner, updateNavigation, updateFooter } from './utils.js';

// Add project-wide style path here.
const STYLES = '/edsdme/styles/styles.css';
Expand Down Expand Up @@ -72,8 +73,14 @@ const miloLibs = setLibs(LIBS);
});
}());

function setUpPage() {
updateNavigation(CONFIG.locales);
updateFooter(CONFIG.locales);
}

(async function loadPage() {
applyPagePersonalization();
setUpPage();
redirectLoggedinPartner();
updateIMSConfig();
await preloadResources(CONFIG.locales, miloLibs);
Expand Down
22 changes: 22 additions & 0 deletions edsdme/scripts/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ export function getMetadataContent(name) {
return document.querySelector(`meta[name="${name}"]`)?.content;
}

export function getMetadata(name) {
return document.querySelector(`meta[name="${name}"]`);
}

export function redirectLoggedinPartner() {
if (!isMember()) return;
const target = getMetadataContent('adobe-target-after-login');
Expand Down Expand Up @@ -375,3 +379,21 @@ export async function preloadResources(locales, miloLibs) {
preload(caasUrl);
});
}

export function updateNavigation(locales) {
const { prefix } = getLocale(locales);
const gnavMeta = getMetadata('gnav-source');
if (!gnavMeta || !isMember()) return;

const gnavLoggedIn = getMetadataContent('gnav-loggedin-source');
gnavMeta.content = gnavLoggedIn ?? `${prefix}/edsdme/partners-shared/loggedin-gnav`;
}

export function updateFooter(locales) {
const { prefix } = getLocale(locales);
const footerMeta = getMetadata('footer-source');
if (!footerMeta || !isMember()) return;

const footerLoggedIn = getMetadataContent('footer-loggedin-source');
footerMeta.content = footerLoggedIn ?? `${prefix}/edsdme/partners-shared/loggedin-footer`;
}
Loading

0 comments on commit b8ba74c

Please sign in to comment.