8 lines
374 B
TypeScript
8 lines
374 B
TypeScript
/** One or two letters from a community name for the Rule card mark. */
|
|
export function communityInitialsFromTitle(title: string): string {
|
|
const parts = title.trim().split(/\s+/).filter(Boolean);
|
|
if (parts.length === 0) return "";
|
|
if (parts.length === 1) return parts[0].slice(0, 2).toUpperCase();
|
|
return `${parts[0][0] ?? ""}${parts[1][0] ?? ""}`.toUpperCase();
|
|
}
|