Skip to content

Commit 0f975a6

Browse files
ogwataclaude
andcommitted
feat(cookbook): wire Cookbook section into PDF/EPUB/WebPub pipeline
The Cookbook section was added as web content only. Other product sections (cli/vfm/themes/viewer/reference) all expose PDF / EPUB / WebPub downloads in the sidebar via <DownloadLinks>; cookbook had neither the build configuration nor the download UI. Add both so cookbook articles are available in the same multi-format set. - Add vivliostyle.config-cookbook-{en,ja}.js modeled after the reference configs. Entry list covers index + 3 cookbook articles (footnotes / cmyk / page-groups). Outputs go to: public/downloads/vivliostyle-cookbook-{en,ja}.pdf public/downloads/vivliostyle-cookbook-{en,ja}.epub public/publications/cookbook-{en,ja}/ - vivliostyle.config-shared.js: extend the PRODUCTS array (and the JSDoc type) to include 'cookbook' so getCopyAssetExcludes correctly excludes other-product paths from cookbook builds and vice versa. - DownloadLinks.astro / LiveView.astro: extend the product type union with 'cookbook' and add the fileBase entry ('vivliostyle-cookbook') so DownloadLinks resolves to the right PDF/EPUB filenames and LiveView builds the right webpub manifest URL. - src/pages/{en,ja}/cookbook/[...slug].astro: import DownloadLinks and place <DownloadLinks product="cookbook" lang=…> inside <nav slot="sidebar"> after the entry list, matching the cli / themes / vfm / viewer slug layouts. - package.json: add build:vivliostyle:cookbook-{en,ja} scripts and append them to the build:vivliostyle chain so CI's existing build:formats step generates cookbook outputs alongside the other products. Verified locally that build:vivliostyle:cookbook-en produces a 2.9 MB PDF, a 4.4 MB EPUB, and the webpub directory cleanly. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 056eb3d commit 0f975a6

8 files changed

Lines changed: 64 additions & 5 deletions

File tree

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"test:watch": "vitest",
1212
"optimize:images": "node scripts/optimize-images.mjs",
1313
"fix:epub-paths": "node scripts/fix-epub-paths.mjs",
14-
"build:vivliostyle": "npm run build:vivliostyle:cli-ja && npm run build:vivliostyle:cli-en && npm run build:vivliostyle:vfm-ja && npm run build:vivliostyle:vfm-en && npm run build:vivliostyle:themes-ja && npm run build:vivliostyle:themes-en && npm run build:vivliostyle:viewer-ja && npm run build:vivliostyle:viewer-en && npm run build:vivliostyle:reference-ja && npm run build:vivliostyle:reference-en",
14+
"build:vivliostyle": "npm run build:vivliostyle:cli-ja && npm run build:vivliostyle:cli-en && npm run build:vivliostyle:vfm-ja && npm run build:vivliostyle:vfm-en && npm run build:vivliostyle:themes-ja && npm run build:vivliostyle:themes-en && npm run build:vivliostyle:viewer-ja && npm run build:vivliostyle:viewer-en && npm run build:vivliostyle:reference-ja && npm run build:vivliostyle:reference-en && npm run build:vivliostyle:cookbook-ja && npm run build:vivliostyle:cookbook-en",
1515
"build:formats": "npm run build:vivliostyle && npm run fix:epub-paths",
1616
"build:vivliostyle:cli-ja": "vivliostyle build -c vivliostyle.config-cli-ja.js",
1717
"build:vivliostyle:cli-en": "vivliostyle build -c vivliostyle.config-cli-en.js",
@@ -23,6 +23,8 @@
2323
"build:vivliostyle:viewer-en": "vivliostyle build -c vivliostyle.config-viewer-en.js",
2424
"build:vivliostyle:reference-ja": "vivliostyle build -c vivliostyle.config-reference-ja.js",
2525
"build:vivliostyle:reference-en": "vivliostyle build -c vivliostyle.config-reference-en.js",
26+
"build:vivliostyle:cookbook-ja": "vivliostyle build -c vivliostyle.config-cookbook-ja.js",
27+
"build:vivliostyle:cookbook-en": "vivliostyle build -c vivliostyle.config-cookbook-en.js",
2628
"build:all": "npm run build && npm run build:formats && npm run copy:formats-to-dist",
2729
"copy:formats-to-dist": "mkdir -p dist/downloads dist/publications && cp -R public/downloads/. dist/downloads/ && cp -R public/publications/. dist/publications/",
2830
"regenerate:symbol-fonts": "python3 scripts/regenerate-symbol-fonts.py"

src/components/DownloadLinks.astro

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import LiveView from './LiveView.astro';
77
88
interface Props {
9-
product: 'cli' | 'vfm' | 'themes' | 'viewer' | 'reference';
9+
product: 'cli' | 'vfm' | 'themes' | 'viewer' | 'reference' | 'cookbook';
1010
lang: 'en' | 'ja';
1111
}
1212
@@ -18,6 +18,7 @@ const fileBase: Record<Props['product'], string> = {
1818
themes: 'vivliostyle-themes',
1919
viewer: 'vivliostyle-viewer',
2020
reference: 'vivliostyle-reference',
21+
cookbook: 'vivliostyle-cookbook',
2122
};
2223
2324
const pdfHref = `/downloads/${fileBase[product]}-${lang}.pdf`;

src/components/LiveView.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* 4. ユーザーは Viewer 内のツールバーで印刷 → ブラウザの「PDFで保存」が使える
1414
*/
1515
interface Props {
16-
product: 'cli' | 'vfm' | 'themes' | 'viewer' | 'reference';
16+
product: 'cli' | 'vfm' | 'themes' | 'viewer' | 'reference' | 'cookbook';
1717
lang: 'en' | 'ja';
1818
}
1919

src/pages/en/cookbook/[...slug].astro

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import DocsLayout from '../../../layouts/DocsLayout.astro';
77
import LanguageSwitcher from '../../../components/LanguageSwitcher.astro';
88
import PageNavigation from '../../../components/PageNavigation.astro';
99
import SidebarTocHeadings from '../../../components/SidebarTocHeadings.astro';
10+
import DownloadLinks from '../../../components/DownloadLinks.astro';
1011
import { getCollection } from 'astro:content';
1112
1213
export async function getStaticPaths() {
@@ -80,6 +81,7 @@ const nextPage = currentIndex < sortedDocs.length - 1 ? sortedDocs[currentIndex
8081
);
8182
})}
8283
</ul>
84+
<DownloadLinks product="cookbook" lang="en" />
8385
</nav>
8486

8587
<article set:html={htmlContent} />

src/pages/ja/cookbook/[...slug].astro

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import DocsLayout from '../../../layouts/DocsLayout.astro';
77
import LanguageSwitcher from '../../../components/LanguageSwitcher.astro';
88
import PageNavigation from '../../../components/PageNavigation.astro';
99
import SidebarTocHeadings from '../../../components/SidebarTocHeadings.astro';
10+
import DownloadLinks from '../../../components/DownloadLinks.astro';
1011
import { getCollection } from 'astro:content';
1112
1213
export async function getStaticPaths() {
@@ -78,6 +79,7 @@ const nextPage = currentIndex < sortedDocs.length - 1 ? sortedDocs[currentIndex
7879
);
7980
})}
8081
</ul>
82+
<DownloadLinks product="cookbook" lang="ja" />
8183
</nav>
8284

8385
<article set:html={htmlContent} />

vivliostyle.config-cookbook-en.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { getCopyAssetExcludes, transformSectionList, transformDocumentList } from './vivliostyle.config-shared.js';
2+
3+
export default {
4+
title: 'Vivliostyle Cookbook',
5+
author: 'Vivliostyle Foundation',
6+
language: 'en',
7+
size: 'A4',
8+
theme: './packages/theme-PDF',
9+
entryContext: 'dist',
10+
entry: [
11+
'en/cookbook/index.html',
12+
'en/cookbook/footnotes/index.html',
13+
'en/cookbook/cmyk/index.html',
14+
'en/cookbook/page-groups/index.html',
15+
],
16+
output: [
17+
{ path: 'public/downloads/vivliostyle-cookbook-en.pdf', format: 'pdf' },
18+
{ path: 'public/downloads/vivliostyle-cookbook-en.epub', format: 'epub' },
19+
{ path: 'public/publications/cookbook-en', format: 'webpub' },
20+
],
21+
workspaceDir: '.vivliostyle/cookbook-en',
22+
toc: { sectionDepth: 3, transformSectionList, transformDocumentList },
23+
copyAsset: {
24+
excludes: getCopyAssetExcludes({ product: 'cookbook', lang: 'en' }),
25+
},
26+
};

vivliostyle.config-cookbook-ja.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { getCopyAssetExcludes, transformSectionList, transformDocumentList } from './vivliostyle.config-shared.js';
2+
3+
export default {
4+
title: 'Vivliostyle 活用ガイド',
5+
author: 'Vivliostyle Foundation',
6+
language: 'ja',
7+
size: 'A4',
8+
theme: './packages/theme-PDF',
9+
entryContext: 'dist',
10+
entry: [
11+
'ja/cookbook/index.html',
12+
'ja/cookbook/footnotes/index.html',
13+
'ja/cookbook/cmyk/index.html',
14+
'ja/cookbook/page-groups/index.html',
15+
],
16+
output: [
17+
{ path: 'public/downloads/vivliostyle-cookbook-ja.pdf', format: 'pdf' },
18+
{ path: 'public/downloads/vivliostyle-cookbook-ja.epub', format: 'epub' },
19+
{ path: 'public/publications/cookbook-ja', format: 'webpub' },
20+
],
21+
workspaceDir: '.vivliostyle/cookbook-ja',
22+
toc: { sectionDepth: 3, transformSectionList, transformDocumentList },
23+
copyAsset: {
24+
excludes: getCopyAssetExcludes({ product: 'cookbook', lang: 'ja' }),
25+
},
26+
};

vivliostyle.config-shared.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
* Vivliostyle CLI コールバック。
1313
*/
1414

15-
const PRODUCTS = ['cli', 'vfm', 'themes', 'viewer', 'reference'];
15+
const PRODUCTS = ['cli', 'vfm', 'themes', 'viewer', 'reference', 'cookbook'];
1616
const ALL_LANGUAGES = ['en', 'ja'];
1717

1818
/**
1919
* 指定したプロダクト・言語のビルドで copyAsset から除外すべきパスを返す。
2020
* パターンは entryContextDir (= `dist/`) からの相対 glob。
2121
*
22-
* @param {{ product: 'cli'|'vfm'|'themes'|'viewer'|'reference', lang: 'en'|'ja' }} options
22+
* @param {{ product: 'cli'|'vfm'|'themes'|'viewer'|'reference'|'cookbook', lang: 'en'|'ja' }} options
2323
*/
2424
export function getCopyAssetExcludes({ product, lang }) {
2525
const otherLanguages = ALL_LANGUAGES.filter((l) => l !== lang);

0 commit comments

Comments
 (0)