Replace manual hashtags and color cycling with content-tone heuristics for blockquotes and tables, and refine blockquote layout with a centered icon, larger sizing, and clearer contrast over background decorations. Co-authored-by: Cursor <cursoragent@cursor.com>
23 lines
625 B
TypeScript
23 lines
625 B
TypeScript
import type { BlockquoteVariant } from "@/lib/blog-blocks";
|
|
import { detectContentTone, stripHtml } from "@/lib/content-tone";
|
|
|
|
/**
|
|
* تشخیص variant نقلقول از روی متن و منبع.
|
|
* اولویت: منبع → هشدار → نکته مثبت → خنثی.
|
|
*/
|
|
export function detectBlockquoteVariant(
|
|
contentHtml: string,
|
|
citation?: string
|
|
): BlockquoteVariant {
|
|
if (citation?.trim()) {
|
|
return "gray";
|
|
}
|
|
|
|
const text = stripHtml(contentHtml);
|
|
const tone = detectContentTone(text);
|
|
|
|
if (tone === "warning") return "yellow";
|
|
if (tone === "positive") return "green";
|
|
return "gray";
|
|
}
|