Files
Epicure/apps/web/lib/mentions.ts
T
Arnaud a51ba85253 feat: @mentions in comments
Parse @username in comment content, notify mentioned users (dedup
against recipe-author/parent-author who are already notified via
comment/reply), and render @username as a link to their profile.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-03 22:16:06 +02:00

12 lines
353 B
TypeScript

const MENTION_REGEX = /@([a-z0-9_-]{3,30})/gi;
export function extractMentionedUsernames(content: string): string[] {
const matches = content.matchAll(MENTION_REGEX);
const usernames = new Set<string>();
for (const m of matches) {
const username = m[1];
if (username) usernames.add(username.toLowerCase());
}
return [...usernames];
}