e962d86ba5
Default open WeChat draft comments, add SEO/visual template rules with h2 sections and mindspace-geo, and compress inline styles to pack more cards within the 20k HTML budget. Co-authored-by: Cursor <cursoragent@cursor.com>
65 lines
2.6 KiB
JavaScript
65 lines
2.6 KiB
JavaScript
#!/usr/bin/env node
|
||
/**
|
||
* Enable full-source news morning template and trigger prod worker regenerate + push.
|
||
*/
|
||
import process from 'node:process';
|
||
import mysql from 'mysql2/promise';
|
||
import { loadH5Environment } from './load-env.mjs';
|
||
|
||
loadH5Environment(import.meta.dirname);
|
||
|
||
const CONFIG_KEY = 'news_morning_draft';
|
||
const CONFIG_TABLE = 'h5_wechat_admin_config';
|
||
|
||
async function main() {
|
||
if (!process.env.DATABASE_URL) {
|
||
console.error('DATABASE_URL missing');
|
||
process.exit(1);
|
||
}
|
||
const pool = mysql.createPool({ uri: process.env.DATABASE_URL, connectionLimit: 2 });
|
||
const [rows] = await pool.query(
|
||
`SELECT config_json FROM ${CONFIG_TABLE} WHERE config_key = ? LIMIT 1`,
|
||
[CONFIG_KEY],
|
||
);
|
||
const current = rows[0]?.config_json
|
||
? (typeof rows[0].config_json === 'string' ? JSON.parse(rows[0].config_json) : rows[0].config_json)
|
||
: {};
|
||
const next = {
|
||
...current,
|
||
enabled: current.enabled !== false,
|
||
forceGenerateOnce: true,
|
||
taskSpecAppend: [
|
||
'【全渠道扩展 · 必须生成且全页去重】',
|
||
'除原有栏目外,必须新增并写满以下 section(quick-link + div.section),每条 2 card(crypto 有则 1~2,无则可省略 section):',
|
||
'asia_pacific / commodities / ai_chips / policy / community / science / culture / startup / crypto / geopolitics / local_life / official_feeds,',
|
||
'以及 google / x / universities / global_markets。',
|
||
'全页去重:同一 URL 或同一核心事件只允许出现一次;主栏目优先,扩展栏目必须换角度或跳过。',
|
||
'禁止 id=hot 热搜栏目;禁止 .stats 或「X条资讯 · Y个栏目」统计行。',
|
||
'SEO:title/description/mindspace-geo/faq 必做;section-title 内用 h2;card 左侧色条 + highlight 渐变。',
|
||
'英文栏目标题可英文,每条必须有中文摘要与来源 URL;禁止整段纯英文正文。',
|
||
].join('\n'),
|
||
};
|
||
const now = Date.now();
|
||
await pool.query(
|
||
`INSERT INTO ${CONFIG_TABLE} (config_key, config_json, updated_by, updated_at)
|
||
VALUES (?, ?, ?, ?)
|
||
ON DUPLICATE KEY UPDATE
|
||
config_json = VALUES(config_json),
|
||
updated_by = VALUES(updated_by),
|
||
updated_at = VALUES(updated_at)`,
|
||
[CONFIG_KEY, JSON.stringify(next), 'full-source-regenerate', now],
|
||
);
|
||
console.log(JSON.stringify({
|
||
ok: true,
|
||
forceGenerateOnce: true,
|
||
taskSpecAppendChars: next.taskSpecAppend.length,
|
||
templateNote: 'Worker must run code with full template + dedupe prefetch for best effect.',
|
||
}, null, 2));
|
||
await pool.end();
|
||
}
|
||
|
||
main().catch((error) => {
|
||
console.error(error instanceof Error ? error.message : error);
|
||
process.exit(1);
|
||
});
|