fix(og): fall back to thumbnail when declared cover file is missing

WeChat link cards were pointing og:image at mindspace-cover paths that
never landed on disk; serve-time injection now uses thumbnail.png instead.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
john
2026-07-04 14:07:49 +08:00
parent 29d9a87d4f
commit 03c46b37c3
4 changed files with 63 additions and 5 deletions
+5
View File
@@ -1,4 +1,5 @@
import crypto from 'node:crypto';
import fs from 'node:fs';
import path from 'node:path';
const INLINE_SCRIPT_PATTERN = /<script\b(?![^>]*\bsrc\b)[^>]*>([\s\S]*?)<\/script>/gi;
@@ -47,6 +48,8 @@ export function decorateMindSpacePublishedHtml({
html,
embed = false,
context,
htmlFilePath = '',
fileExists = fs.existsSync,
userAgent = '',
preparePublicationHtmlForEmbed,
injectOgTags,
@@ -69,6 +72,8 @@ export function decorateMindSpacePublishedHtml({
pageUrl: context.pageUrl,
pageDirUrl: context.pageDirUrl,
fallbackImageUrl: context.fallbackImageUrl,
htmlFilePath,
fileExists,
});
const wechatShare = !embed && isWechatUserAgent(userAgent || '');
if (wechatShare) {