Skip to content

Commit 62c0f0d

Browse files
ogwataclaude
andcommitted
fix(layout): build the page title in frontmatter to stop body-leak
The <title> element was assembled inline inside the head: <title>{title}{lang === 'ja' ? '|' : ' | '}Vivliostyle Documentation</title> Astro's parser was treating the trailing literal string `Vivliostyle Documentation` and the close `</title>` separately from the JSX expressions, which caused the static build to: 1. close <title> right after the ternary (so the title became e.g. `活用ガイド|` with no "Vivliostyle Documentation"), 2. emit `Vivliostyle Documentation` as raw text after </head>, 3. fall back to dumping the rest of the layout's head content as raw text into the body — including the literal source text `isJa && ( )` from the next conditional block. For web pages the leaked text was hidden by layout CSS so it went unnoticed, but Vivliostyle CLI rendered it as a visible orphan string on a blank cover page in every product's PDF / EPUB (reported on vivliostyle-cookbook-ja.pdf, but cli/themes/vfm/ viewer/reference/cookbook all share the issue). Compute fullTitle in the frontmatter as a plain template string and substitute it with a single `{fullTitle}` interpolation. This keeps the entire title atomic from the parser's standpoint and the rest of <head> stays in <head>. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 30da0ec commit 62c0f0d

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/layouts/DocsLayout.astro

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const { title, description = '', lang = 'en', showBreadcrumb = true, availableLa
1919
const currentPath = Astro.url.pathname;
2020
2121
const isJa = lang === 'ja';
22+
const fullTitle = `${title}${isJa ? '' : ' | '}Vivliostyle Documentation`;
2223
const navLabels = isJa
2324
? {
2425
product: 'プロダクト',
@@ -81,7 +82,7 @@ const navLinks = {
8182
<meta charset="UTF-8">
8283
<meta name="viewport" content="width=device-width, initial-scale=1.0">
8384
<meta name="description" content={description}>
84-
<title>{title}{lang === 'ja' ? '' : ' | '}Vivliostyle Documentation</title>
85+
<title>{fullTitle}</title>
8586
<link rel="icon" type="image/png" href="/favicon.png">
8687
<link rel="canonical" href={`${Astro.url.origin}${currentPath}`}>
8788
{availableLanguages.map((language) => (

0 commit comments

Comments
 (0)