Skip to content

Commit

Permalink
DA Live Preview (#256)
Browse files Browse the repository at this point in the history
* 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/

* Update 404.html

Remove use credentials.

1. This property is not necessary.
2. This property breaks da live preview.

---------

Co-authored-by: Stephen <[email protected]>
  • Loading branch information
auniverseaway and sirugh authored Dec 16, 2024
1 parent 9eee699 commit 6b3b38f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion 404.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</script>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta property="og:title" content="Page not found">
<script src="/scripts/scripts.js" type="module" crossorigin="use-credentials"></script>
<script src="/scripts/scripts.js" type="module"></script>
<script type="module">
window.addEventListener('load', () => {
if (document.referrer) {
Expand Down
6 changes: 6 additions & 0 deletions scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,3 +374,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));
}());

0 comments on commit 6b3b38f

Please sign in to comment.