fix: stabilize docs demo runtime routing
This commit is contained in:
+11
-10
@@ -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
|
||||
|
||||
@@ -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"),
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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",
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -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 служат полноэкранной обвязкой с верхней панелью возврата в документацию, а внешняя страница синхронизирует читаемый адрес демо.
|
||||
|
||||
Reference in New Issue
Block a user