From dde4aea2e8eda09bbf481dacb03c22817dde62a7 Mon Sep 17 00:00:00 2001 From: artem Date: Sat, 19 Sep 2026 00:37:35 +0300 Subject: [PATCH] ssr --- server/index.ts | 8 +++++--- src/layouts/AppLayout.vue | 2 +- src/router/index.ts | 5 ++++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/server/index.ts b/server/index.ts index b0544fd..02555e8 100644 --- a/server/index.ts +++ b/server/index.ts @@ -18,7 +18,8 @@ function getAssetTagsSafe(): string { } } -function escapeHtml(text: string): string { +function escapeHtml(text: string | null | undefined): string { + if (!text) return ""; return text.replace(//g, ">"); } @@ -188,8 +189,9 @@ app.get("/public/workouts/:id", async (req: Request, res: Response) => {
  • Длительность: ${formatDuration(w.duraion_sec)}
  • `; - const desc = - w.description.slice(0, 150) + (w.description.length > 150 ? "…" : ""); + const desc = w.description + ? w.description.slice(0, 150) + (w.description.length > 150 ? "…" : "") + : ""; const metrics = `${formatDistance(w.distantion)} км, ${formatSpeed(w.speed)} км/ч, пульс ${w.heart_rate}, мощность ${w.power} Вт`; const meta: SeoMeta = { diff --git a/src/layouts/AppLayout.vue b/src/layouts/AppLayout.vue index e024b61..b4e4506 100644 --- a/src/layouts/AppLayout.vue +++ b/src/layouts/AppLayout.vue @@ -79,7 +79,7 @@ const onResize = () => { onMounted(() => { const token = localStorage.getItem("token"); - if (!token && useRoute().path != "/explore") { + if (!token && useRoute().path != "/explore" && useRoute().path != "/") { useRouter().push({ name: "login" }); } window.addEventListener("resize", onResize); diff --git a/src/router/index.ts b/src/router/index.ts index 0730da7..ae229db 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -21,8 +21,11 @@ const routes: Array = [ name: "admin", path: "/", component: AppLayout, - redirect: { name: "explore" }, children: [ + { + path: "", + component: () => import("../pages/LandingRedirect.vue"), + }, { name: "explore", path: "explore",