File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -249,6 +249,40 @@ Deno.test({
249249 } ,
250250} ) ;
251251
252+ Deno . test ( {
253+ name : 'buildPlugin - SPA shell uses configured html title and lang' ,
254+ sanitizeOps : false ,
255+ sanitizeResources : false ,
256+ async fn ( ) {
257+ const root = await Deno . makeTempDir ( ) ;
258+ try {
259+ await Deno . mkdir ( `${ root } /app/routes` , { recursive : true } ) ;
260+
261+ const ctx = new OpenElementBuildContext ( { mode : 'spa' } ) ;
262+ const plugin = buildPlugin ( {
263+ mode : 'spa' ,
264+ routesDir : 'app/routes' ,
265+ build : { outDir : 'dist' } ,
266+ html : {
267+ lang : 'zh-CN' ,
268+ title : 'Reader <Alpha>' ,
269+ } ,
270+ } , ctx ) ;
271+ const config = makeConfig ( 'build' ) ;
272+ config . root = root ;
273+ callHook ( plugin . configResolved , config ) ;
274+
275+ await callAsyncHook ( plugin . closeBundle ) ;
276+
277+ const html = await Deno . readTextFile ( `${ root } /dist/index.html` ) ;
278+ assertStringIncludes ( html , '<html lang="zh-CN">' ) ;
279+ assertStringIncludes ( html , '<title>Reader <Alpha></title>' ) ;
280+ } finally {
281+ await Deno . remove ( root , { recursive : true } ) ;
282+ }
283+ } ,
284+ } ) ;
285+
252286Deno . test ( {
253287 name : 'buildPlugin - ssr.noExternal RegExp serialization writes to ctx' ,
254288 // Rolldown/Vite SSR build spawns dangling async fs.access (Deno.lstat) ops
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import type { OpenElementBuildContext } from './build-context.js';
1414import { join } from 'node:path' ;
1515import process from 'node:process' ;
1616import { createLogger } from '@openelement/core/logger' ;
17+ import { escapeAttr , escapeHtml } from '@openelement/core' ;
1718import { cleanSsrArtifacts , postProcessClientIslandBuild } from '@openelement/ssg' ;
1819import { writeRouteManifest } from './route-manifest.js' ;
1920
@@ -76,13 +77,15 @@ export function buildPlugin(
7677 const outDirName = ctx . phase3 . outDir || 'dist' ;
7778 const absOutDir = join ( root , outDirName ) ;
7879 const base = ctx . phase3 . base || '/' ;
80+ const htmlLang = escapeAttr ( ctx . phase3 . html ?. lang ?? 'en' ) ;
81+ const htmlTitle = escapeHtml ( ctx . phase3 . html ?. title ?? 'openElement App' ) ;
7982
8083 // Generate SPA shell HTML
8184 const html = `<!DOCTYPE html>
82- <html lang="en ">
85+ <html lang="${ htmlLang } ">
8386<head>
8487 <meta charset="UTF-8">
85- <title>openElement Reader </title>
88+ <title>${ htmlTitle } </title>
8689</head>
8790<body>
8891 <div id="root"></div>
You can’t perform that action at this time.
0 commit comments