Hey is a decentralized and permissionless social media app built with Lens Protocol 馃尶
1import { Regex } from "@hey/data/regex";
2import type { AccountMentionFragment, PostMentionFragment } from "@hey/indexer";
3
4const getMentions = (text: string): PostMentionFragment[] => {
5 if (!text) return [];
6
7 const mentions = text.match(Regex.mention) ?? [];
8
9 return mentions.map((mention) => {
10 const handle = mention
11 .substring(mention.lastIndexOf("/") + 1)
12 .toLowerCase();
13
14 return {
15 account: "",
16 namespace: "",
17 replace: { from: handle, to: handle }
18 } as AccountMentionFragment;
19 });
20};
21
22export default getMentions;