From 6b0d9a29db0b20e8deb6f52a7263b1d7cd59cbd1 Mon Sep 17 00:00:00 2001 From: Chris Millar Date: Fri, 13 Dec 2024 07:53:27 -0700 Subject: [PATCH] DA Live Preview Add live preview support for Document Authoring for customers who use the new Commerce Scaffold CLI. ## Note: If there is no query param, the script will not be imported. Either way, this runs after loadPage and does not impact performance. Before: https://main--aem-boilerplate-commerce--hlxsites.hlx.page/ After: https://da-live-preview--aem-boilerplate-commerce--hlxsites.hlx.page/ --- scripts/scripts.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/scripts.js b/scripts/scripts.js index 14babc377..e5bf3461b 100644 --- a/scripts/scripts.js +++ b/scripts/scripts.js @@ -328,3 +328,9 @@ async function loadPage() { } loadPage(); + +(async function loadDa() { + if (!new URL(window.location.href).searchParams.get('dapreview')) return; + // eslint-disable-next-line import/no-unresolved + import('https://da.live/scripts/dapreview.js').then(({ default: daPreview }) => daPreview(loadPage)); +}());