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
+6 -1
View File
@@ -22,7 +22,12 @@ export async function getMemosIdentity(baseUrl: string, token: string) {
if (!user.name) throw new Error("Memos did not return an account identity");
return user;
}
export function memoUrl(baseUrl: string, memoName: string) { const id = memoName.split("/").at(-1); return id ? `${baseUrl.replace(/\/$/, "")}/m/${encodeURIComponent(id)}` : null; }
export function memoUrl(baseUrl: string, memoName: string) {
const id = memoName.split("/").at(-1);
if (!id) return null;
const path = /^\d+$/.test(id) ? `m/${encodeURIComponent(id)}` : `memos/${encodeURIComponent(id)}`;
return `${baseUrl.replace(/\/$/, "")}/${path}`;
}
export type MemosPage = { memos: MemosMemo[]; nextPageToken: string };
export async function listMemos(baseUrl: string, token: string, rules: MemosSyncRules = {}, page: { pageToken?: string; pageSize?: number } = {}): Promise<MemosPage> {
let pageToken = page.pageToken || "";