fix layout SSR translations and remediation follow-ups

This commit is contained in:
2026-08-09 18:49:16 +05:30
parent 51286d0fa3
commit 7d87200e31
10 changed files with 160 additions and 89 deletions
+2 -1
View File
@@ -6,7 +6,7 @@
* the running process while the HMR socket morphs fresh HTML into the browser.
*/
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
import { mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { resolve, dirname, isAbsolute, join } from "node:path";
import type { Middleware, Mode, SecurityConfig, SeoConfig } from "@wrnexus/core";
import { buildRouter, type Router } from "@wrnexus/router";
@@ -744,6 +744,7 @@ export async function startServer(opts: ServeOptions): Promise<RunningServer> {
unsubscribeDevToolbar?.();
server.stop();
void pluginRunner.hook("shutdown");
rmSync(cacheDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
},
};
}
+8 -1
View File
@@ -1815,7 +1815,14 @@ export function createHandlers(deps: RuntimeDeps): Handlers {
if (isMobileRequest) body = revealMobileOnlyHtml(body);
// i18n: resolve `{t:key}` / `t:attr` markers against the request language.
if (deps.i18n) body = translateHtml(body, ctx.t);
if (deps.i18n) {
body = translateHtml(body, ctx.t);
// renderDocument prefers the complete document template when one was
// rendered. Keep it in sync with the translated body; otherwise markers
// owned by document/page layouts are replaced by the stale pre-translation
// template even though page-only responses translate correctly.
if (documentTemplate) documentTemplate = body;
}
// Point 3: only ship the JS this page actually uses.
const scripts = collectScripts(body, deps.clientRuntimes, deps.navigation).map((script) =>