fix: load docs demo runtime index directly
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
const frame = document.getElementById("demo-frame");
|
const frame = document.getElementById("demo-frame");
|
||||||
const runtimeBase = "/demo/runtime";
|
const runtimeBase = "/demo/runtime";
|
||||||
|
const runtimeAppPath = `${runtimeBase}/app/index.html`;
|
||||||
const demoBase = "/demo";
|
const demoBase = "/demo";
|
||||||
const defaultMock = "tariffs";
|
const defaultMock = "tariffs";
|
||||||
const publicRouteAliases = new Map([["/app", "/home"]]);
|
const publicRouteAliases = new Map([["/app", "/home"]]);
|
||||||
@@ -145,7 +146,7 @@ if (initialMock !== "emails") {
|
|||||||
params.delete("screen");
|
params.delete("screen");
|
||||||
params.delete("admin_section");
|
params.delete("admin_section");
|
||||||
params.set("path", initialRoute);
|
params.set("path", initialRoute);
|
||||||
frame.src = `${runtimeBase}/app/?${params.toString()}${window.location.hash || ""}`;
|
frame.src = `${runtimeAppPath}?${params.toString()}${window.location.hash || ""}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const routeFromRuntimeUrl = (url) => {
|
const routeFromRuntimeUrl = (url) => {
|
||||||
@@ -155,7 +156,11 @@ const routeFromRuntimeUrl = (url) => {
|
|||||||
const runtimePath = normalizePath(
|
const runtimePath = normalizePath(
|
||||||
url.pathname.slice(runtimeBase.length) || "/home",
|
url.pathname.slice(runtimeBase.length) || "/home",
|
||||||
);
|
);
|
||||||
if (runtimePath === "/app" || runtimePath === "/app.html") {
|
if (
|
||||||
|
runtimePath === "/app" ||
|
||||||
|
runtimePath === "/app/index.html" ||
|
||||||
|
runtimePath === "/app.html"
|
||||||
|
) {
|
||||||
return normalizePath(url.searchParams.get("path") || "/home");
|
return normalizePath(url.searchParams.get("path") || "/home");
|
||||||
}
|
}
|
||||||
return runtimePath;
|
return runtimePath;
|
||||||
@@ -171,7 +176,7 @@ const runtimeSrc = (route, searchParams = new URLSearchParams()) => {
|
|||||||
nextParams.delete("screen");
|
nextParams.delete("screen");
|
||||||
nextParams.delete("admin_section");
|
nextParams.delete("admin_section");
|
||||||
nextParams.set("path", normalizePath(route));
|
nextParams.set("path", normalizePath(route));
|
||||||
return `${runtimeBase}/app/?${nextParams.toString()}${window.location.hash || ""}`;
|
return `${runtimeAppPath}?${nextParams.toString()}${window.location.hash || ""}`;
|
||||||
};
|
};
|
||||||
const topbar = document.querySelector(".demo-topbar");
|
const topbar = document.querySelector(".demo-topbar");
|
||||||
const toggle = document.querySelector(".demo-topbar__toggle");
|
const toggle = document.querySelector(".demo-topbar__toggle");
|
||||||
@@ -226,7 +231,8 @@ const setCollapsed = (collapsed) => {
|
|||||||
|
|
||||||
toggle?.addEventListener("click", () => setCollapsed(false));
|
toggle?.addEventListener("click", () => setCollapsed(false));
|
||||||
hide?.addEventListener("click", () => setCollapsed(true));
|
hide?.addEventListener("click", () => setCollapsed(true));
|
||||||
if (stateSelect) stateSelect.value = normalizeStateMock(params.get("mock") || initialMock);
|
if (stateSelect)
|
||||||
|
stateSelect.value = normalizeStateMock(params.get("mock") || initialMock);
|
||||||
setDemoMode(initialMock);
|
setDemoMode(initialMock);
|
||||||
stateSelect?.addEventListener("change", () => {
|
stateSelect?.addEventListener("change", () => {
|
||||||
const mock = normalizeStateMock(stateSelect.value);
|
const mock = normalizeStateMock(stateSelect.value);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
import { emailPreviews } from '../lib/emailPreviews.mjs';
|
import { emailPreviews } from '../lib/emailPreviews.mjs';
|
||||||
|
|
||||||
const defaultDemoSrc = '/demo/runtime/app/?path=/home&mock=tariffs';
|
const defaultDemoSrc = '/demo/runtime/app/index.html?path=/home&mock=tariffs';
|
||||||
const docsHref = '/getting-started/demo/';
|
const docsHref = '/getting-started/demo/';
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -529,7 +529,7 @@ const docsHref = '/getting-started/demo/';
|
|||||||
title={`Email preview: ${preview.title}`}
|
title={`Email preview: ${preview.title}`}
|
||||||
srcdoc={preview.html}
|
srcdoc={preview.html}
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
sandbox=""
|
sandbox="allow-scripts"
|
||||||
></iframe>
|
></iframe>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user