Files

23 lines
625 B
TypeScript
Raw Permalink Normal View History

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";
}