Skip to content

Commit

Permalink
Only run when MEP or MEP param is enabled (#1156)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrischrischris authored Aug 24, 2023
1 parent 051ad70 commit 95eb4cc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
3 changes: 1 addition & 2 deletions libs/features/personalization/add-preview-to-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ export default async function addPreviewToConfig({
pageUrl,
persEnabled,
persManifests,
previewPage,
targetEnabled,
}) {
const { mep: mepOverride, mepHighlight, mepButton } = Object.fromEntries(pageUrl.searchParams);
const config = updateConfig({
...getConfig(),
mep: {
preview: (mepButton !== 'off' && (mepOverride !== undefined || (previewPage && (persEnabled || targetEnabled)))),
preview: (mepButton !== 'off' && (mepOverride !== undefined || persEnabled || targetEnabled)),
override: mepOverride ? decodeURIComponent(mepOverride) : '',
highlight: (mepHighlight !== undefined && mepHighlight !== 'false'),
},
Expand Down
6 changes: 2 additions & 4 deletions libs/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -739,16 +739,14 @@ async function checkForPageMods() {
.filter((path) => path?.trim());
}

const { mep: mepOverride } = Object.fromEntries(PAGE_URL.searchParams);
const { env } = getConfig();
const previewPage = env?.name === 'stage' || env?.name === 'local';
if (mepOverride || mepOverride === '' || previewPage) {
const mep = PAGE_URL.searchParams.get('mep');
if (mep !== null || (env.name !== 'prod' && (persEnabled || targetEnabled))) {
const { default: addPreviewToConfig } = await import('../features/personalization/add-preview-to-config.js');
persManifests = await addPreviewToConfig({
pageUrl: PAGE_URL,
persEnabled,
persManifests,
previewPage,
targetEnabled,
});
}
Expand Down

0 comments on commit 95eb4cc

Please sign in to comment.