fix(baoyu-post-to-wechat): improve title extraction, summary auto-fill, and content verification

This commit is contained in:
Jim Liu 宝玉
2026-01-27 10:06:11 -06:00
parent 0727296592
commit b1af3a3e45
2 changed files with 64 additions and 8 deletions
@@ -121,8 +121,14 @@ export async function convertMarkdown(markdownPath: string, options?: { title?:
let title = options?.title ?? frontmatter.title ?? '';
if (!title) {
const h1Match = body.match(/^#\s+(.+)$/m);
if (h1Match) title = h1Match[1]!;
const lines = body.split('\n');
for (const line of lines) {
const trimmed = line.trim();
if (!trimmed) continue;
const headingMatch = trimmed.match(/^#{1,2}\s+(.+)$/);
if (headingMatch) title = headingMatch[1]!;
break;
}
}
if (!title) title = path.basename(markdownPath, path.extname(markdownPath));
const author = frontmatter.author || '';