From 19f7daff6cc11e9f203ceed8bd06fbbe05be98b2 Mon Sep 17 00:00:00 2001 From: 3252a8 <3252a8@proton.me> Date: Sun, 31 May 2026 00:25:23 +0300 Subject: [PATCH] fix: stabilize docs demo runtime routing --- docs-site/public/_redirects | 21 ++++++++++--------- docs-site/scripts/build-demo-runtime.mjs | 3 ++- docs-site/scripts/materialize-demo-routes.mjs | 8 ++++++- docs-site/src/pages/demo/runtime/app/index.js | 14 ------------- docs/getting-started/demo.md | 2 +- 5 files changed, 21 insertions(+), 27 deletions(-) delete mode 100644 docs-site/src/pages/demo/runtime/app/index.js diff --git a/docs-site/public/_redirects b/docs-site/public/_redirects index 72bf040..26e2b14 100644 --- a/docs-site/public/_redirects +++ b/docs-site/public/_redirects @@ -1,11 +1,12 @@ # Cloudflare Pages rewrites for non-materialized static docs demo runtime routes. -# Use the directory entrypoint so Pages clean URLs do not loop between app.html and app. -/demo/runtime/home/* /demo/runtime/app/ 200 -/demo/runtime/install/* /demo/runtime/app/ 200 -/demo/runtime/trial/* /demo/runtime/app/ 200 -/demo/runtime/invite/* /demo/runtime/app/ 200 -/demo/runtime/devices/* /demo/runtime/app/ 200 -/demo/runtime/support/* /demo/runtime/app/ 200 -/demo/runtime/settings/* /demo/runtime/app/ 200 -/demo/runtime/login/* /demo/runtime/app/ 200 -/demo/runtime/admin/* /demo/runtime/app/ 200 +# Use the generated directory index instead of app.html so Pages clean URLs do not +# loop between extensionless and .html variants. +/demo/runtime/home/* /demo/runtime/app/index.html 200 +/demo/runtime/install/* /demo/runtime/app/index.html 200 +/demo/runtime/trial/* /demo/runtime/app/index.html 200 +/demo/runtime/invite/* /demo/runtime/app/index.html 200 +/demo/runtime/devices/* /demo/runtime/app/index.html 200 +/demo/runtime/support/* /demo/runtime/app/index.html 200 +/demo/runtime/settings/* /demo/runtime/app/index.html 200 +/demo/runtime/login/* /demo/runtime/app/index.html 200 +/demo/runtime/admin/* /demo/runtime/app/index.html 200 diff --git a/docs-site/scripts/build-demo-runtime.mjs b/docs-site/scripts/build-demo-runtime.mjs index 4a96b3a..09294d1 100644 --- a/docs-site/scripts/build-demo-runtime.mjs +++ b/docs-site/scripts/build-demo-runtime.mjs @@ -191,6 +191,7 @@ await runNpm(["--prefix", frontendRoot, "run", "build:docs-demo"]); await rm(runtimeDir, { recursive: true, force: true }); await mkdir(runtimeDir, { recursive: true }); +await mkdir(path.join(runtimeDir, "app"), { recursive: true }); const html = await appHtml(); @@ -204,7 +205,7 @@ await Promise.all([ path.join(runtimeDir, "default-brand"), ), copyDirectory(themesDir, path.join(runtimeDir, "themes"), copyThemeFile), - writeFile(path.join(runtimeDir, "app.html"), html, "utf8"), + writeFile(path.join(runtimeDir, "app", "index.html"), html, "utf8"), installGuidesConfigPayload().then((payload) => writeFile( path.join(runtimeDir, "subscription-guides-config.json"), diff --git a/docs-site/scripts/materialize-demo-routes.mjs b/docs-site/scripts/materialize-demo-routes.mjs index 239badb..ab0a411 100644 --- a/docs-site/scripts/materialize-demo-routes.mjs +++ b/docs-site/scripts/materialize-demo-routes.mjs @@ -19,7 +19,13 @@ async function copyHtml(source, route) { } const demoShell = path.join(distRoot, "demo", "index.html"); -const runtimeApp = path.join(distRoot, "demo", "runtime", "app.html"); +const runtimeApp = path.join( + distRoot, + "demo", + "runtime", + "app", + "index.html", +); for (const route of demoRoutes) { await copyHtml(demoShell, route); diff --git a/docs-site/src/pages/demo/runtime/app/index.js b/docs-site/src/pages/demo/runtime/app/index.js deleted file mode 100644 index f488870..0000000 --- a/docs-site/src/pages/demo/runtime/app/index.js +++ /dev/null @@ -1,14 +0,0 @@ -import { readFile } from "node:fs/promises"; -import path from "node:path"; - -const runtimeAppHtml = path.join(process.cwd(), "public", "demo", "runtime", "app.html"); - -export const prerender = true; - -export async function GET() { - return new Response(await readFile(runtimeAppHtml, "utf8"), { - headers: { - "Content-Type": "text/html; charset=utf-8", - }, - }); -} diff --git a/docs/getting-started/demo.md b/docs/getting-started/demo.md index 8bfc7a7..c3e6caa 100644 --- a/docs/getting-started/demo.md +++ b/docs/getting-started/demo.md @@ -23,7 +23,7 @@ - использует entrypoint `frontend/src/docsDemoEntry.js`, где подключены моковые данные и mock API; - дополнительно собирает обычный admin-бандл, чтобы админка работала внутри демо; - копирует JS/CSS, темы, default-brand ассеты, локали и конфиг гайдов подключения в `docs-site/public/demo/runtime/`; -- генерирует `app.html`, который грузит demo runtime и встроенные переводы; +- генерирует `app/index.html`, который грузит demo runtime и встроенные переводы; - после Astro build материализует публичные страницы `/demo/home`, `/demo/install`, `/demo/admin/stats` и другие основные demo routes как статические `index.html`; - Cloudflare Pages rewrite-правила остаются только для внутреннего `/demo/runtime/*`, чтобы iframe мог использовать обычный History API без влияния на остальные страницы документации; - страницы `/demo/home`, `/demo/install`, `/demo/admin/*` и другие demo routes служат полноэкранной обвязкой с верхней панелью возврата в документацию, а внешняя страница синхронизирует читаемый адрес демо.