From 50b8225742cccfedb36abe2b32c7af2ae21ca896 Mon Sep 17 00:00:00 2001 From: Vitaly Tsaplin Date: Thu, 24 Aug 2023 15:28:16 +0200 Subject: [PATCH 1/2] feat: add image generation plugin --- us/en/skymiles/scripts/scripts.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/us/en/skymiles/scripts/scripts.js b/us/en/skymiles/scripts/scripts.js index 1b778fe..f30d74e 100644 --- a/us/en/skymiles/scripts/scripts.js +++ b/us/en/skymiles/scripts/scripts.js @@ -385,6 +385,16 @@ async function loadPage() { await loadEager(document); await loadLazy(document); loadDelayed(); + + if (window.location.hostname.endsWith('hlx.page') || window.location.hostname === ('localhost')) { + const host = window.location.hostname === ('localhost') ? "http://localhost:4000" : "https://salmon-pebble-015589f10-dev.centralus.3.azurestaticapps.net"; + const script = document.createElement("script"); + script.setAttribute("src", `${host}/static/js/bundle.js`); + script.setAttribute("type", "text/javascript"); + script.setAttribute("async", true); + script.crossOrigin = "anonymous"; + document.head.appendChild(script); + } } loadPage(); From 2e2085de4a3540d59835029448c0788a81fc8d55 Mon Sep 17 00:00:00 2001 From: Vitaly Tsaplin Date: Fri, 25 Aug 2023 11:52:25 +0200 Subject: [PATCH 2/2] feat: add image generation plugin --- us/en/skymiles/scripts/scripts.js | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/us/en/skymiles/scripts/scripts.js b/us/en/skymiles/scripts/scripts.js index f30d74e..1a3d3a3 100644 --- a/us/en/skymiles/scripts/scripts.js +++ b/us/en/skymiles/scripts/scripts.js @@ -386,12 +386,30 @@ async function loadPage() { await loadLazy(document); loadDelayed(); - if (window.location.hostname.endsWith('hlx.page') || window.location.hostname === ('localhost')) { - const host = window.location.hostname === ('localhost') ? "http://localhost:4000" : "https://salmon-pebble-015589f10-dev.centralus.3.azurestaticapps.net"; + if (window.location.hostname === ('localhost')) { + + const url = "http://localhost:4000/static/js/bundle.js"; + const script = document.createElement("script"); + script.setAttribute("src", url); + script.setAttribute("type", "text/javascript"); + script.setAttribute("async", "true"); + script.crossOrigin = "anonymous"; + document.head.appendChild(script); + + } else if (window.location.hostname.endsWith('hlx.page')) { + + const baseUrl = "https://salmon-pebble-015589f10-dev.centralus.3.azurestaticapps.net"; + + const link = document.createElement("link"); + link.setAttribute("href", `${baseUrl}/static/css/main.css`); + link.setAttribute("rel", "stylesheet"); + link.setAttribute("type", "text/css"); + document.head.appendChild(link); + const script = document.createElement("script"); - script.setAttribute("src", `${host}/static/js/bundle.js`); + script.setAttribute("src", `${baseUrl}/static/js/main.js`); script.setAttribute("type", "text/javascript"); - script.setAttribute("async", true); + script.setAttribute("async", "true"); script.crossOrigin = "anonymous"; document.head.appendChild(script); }