feat: auto-detect blockquote and table colors from content
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>
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
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";
|
||||
}
|
||||
Reference in New Issue
Block a user