fix: correct Memos links and author identities

This commit is contained in:
2026-07-19 18:51:16 +08:00
parent d512443d00
commit 08059e2a9d
11 changed files with 41 additions and 21 deletions
+5 -4
View File
@@ -2,15 +2,16 @@ export type AuthorDisplay = {
origin: string;
username: string;
name: string | null;
remote_user?: 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) {
const remoteUser = post.remote_user?.split("/").filter(Boolean).at(-1);
const author = remoteUser || (post.origin === "rss" ? post.name : post.username) || post.name || "unknown";
if (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}` : ""}`;
return `@${author}`;
}