- NotificationBell: refetchInterval 30000->10000, refetchOnWindowFocus, i18n label - ProfileTabs: Mux thumbnail for VIDEO posts in grid, play icon overlay - parse-caption: add mention segment type for @word parsing - MentionTextarea: new component with @-autocomplete via search.pets - PostCard: render @mentions as blue links to /search - CommentSheet: parse comment bodies for mentions, use MentionTextarea - PhotoPostForm: use MentionTextarea for caption input
20 lines
650 B
TypeScript
20 lines
650 B
TypeScript
export type CaptionSegment =
|
|
| { type: "text"; text: string }
|
|
| { type: "hashtag"; tag: string }
|
|
| { type: "mention"; name: string };
|
|
|
|
export function parseCaption(caption: string): CaptionSegment[] {
|
|
const segments: CaptionSegment[] = [];
|
|
const parts = caption.split(/(#\w{1,50}|@\w{1,50})/g);
|
|
for (const part of parts) {
|
|
if (part.startsWith("#")) {
|
|
segments.push({ type: "hashtag", tag: part.slice(1).toLowerCase() });
|
|
} else if (part.startsWith("@")) {
|
|
segments.push({ type: "mention", name: part.slice(1) });
|
|
} else if (part) {
|
|
segments.push({ type: "text", text: part });
|
|
}
|
|
}
|
|
return segments;
|
|
}
|