feat: show source-qualified author names
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
export type AuthorDisplay = {
|
||||
origin: string;
|
||||
username: string;
|
||||
name: string | null;
|
||||
remote_display_name?: string | null;
|
||||
source_base_url: string | null;
|
||||
};
|
||||
|
||||
export function postAuthorLabel(post: AuthorDisplay) {
|
||||
const linkedMemos = post.origin === "memos" || post.origin === "hub";
|
||||
const author = linkedMemos ? (post.remote_display_name || post.name || post.username) : (post.name || post.username);
|
||||
if (linkedMemos && post.source_base_url) {
|
||||
try { return `@${author}@${new URL(post.source_base_url).hostname}`; } catch { /* Keep a readable fallback for legacy malformed URLs. */ }
|
||||
}
|
||||
return `@${author}${post.name ? ` · ${post.name}` : ""}`;
|
||||
}
|
||||
Reference in New Issue
Block a user