chore: log meta info lines

This commit is contained in:
rca 2025-12-01 16:18:34 +09:00
parent 8a65b03780
commit 6706af5f8e
4 changed files with 28 additions and 14 deletions

View File

@ -33,6 +33,7 @@ TypeScript ベースの Markdown → HTML → PDF 変換パイプラインです
copyright: rca
```
- `frontCover` / `backCover` の各値は任意で、未指定時には `title``published` などの共通値が利用されます。
- `description``<meta name="description">` と表紙/奥付の本文に表示されます。長すぎる場合は YAML 側で適宜整形してください。
## 移植元
- https://github.com/2SC1815J/md2pdf

View File

@ -1,13 +1,5 @@
title: Template
author: ろむねこ
published: 0000/000/00
description: ""
copyright: template
frontCover:
title: Template
author: ろむねこ
published: 0000/000/00
backCover:
title: Template
pubDate: 0000/000/00
copyright: template
title: 寿がきやモバイルオーダーシステム 設計書
author: さkすあsかづさdkす
published: 2025/12/01
description: DESCRIPTIONあるよ〜
copyright: COPYRIGHT

View File

@ -100,9 +100,23 @@ export async function loadMeta(): Promise<DocumentMeta> {
const fullPath = path.join(DOCUMENTS_DIR, filename);
if (await pathExists(fullPath)) {
logger.info(`メタ情報ファイル ${filename} を読み込みます`);
return loadYamlMeta(fullPath);
const meta = await loadYamlMeta(fullPath);
logMetaInfo(meta, filename);
return meta;
}
}
logger.info('メタ情報ファイルが見つからなかったため、テンプレートのデフォルト値を使用します');
logMetaInfo(DEFAULT_META, 'default');
return DEFAULT_META;
}
function logMetaInfo(meta: DocumentMeta, source: string) {
logger.info(`\tsource: ${source}`);
logger.info(`\ttitle: ${meta.title}`);
logger.info(`\tauthor: ${meta.author}`);
logger.info(`\tpublished: ${meta.published}`);
if (meta.description) {
logger.info(`\tdescription: ${meta.description}`);
}
logger.info(`\tcopyright: ${meta.copyright}`);
}

View File

@ -16,6 +16,9 @@
<h1><%= (meta.frontCover && meta.frontCover.title) || meta.title %></h1>
<div class="Published"><%= (meta.frontCover && (meta.frontCover.published || meta.frontCover.pubDate)) || meta.published %></div>
<div class="Author"><%= (meta.frontCover && meta.frontCover.author) || meta.author %></div>
<% if (meta.description && meta.description.length > 0) { %>
<p class="Description"><%= meta.description %></p>
<% } %>
</div>
<article class="markdown-body">
<%- include('../work/all_md.html') %>
@ -25,6 +28,10 @@
<span class="Title"><%= (meta.backCover && meta.backCover.title) || meta.title %></span><br>
<span class="PubDate"><%= (meta.backCover && (meta.backCover.pubDate || meta.backCover.published)) || meta.published %></span><br>
<span class="Copyright"><%= (meta.backCover && meta.backCover.copyright) || meta.copyright %></span>
<% if (meta.description && meta.description.length > 0) { %>
<br>
<span class="Description"><%= meta.description %></span>
<% } %>
</div>
</div>
</body>