diigo-cache: public list shows each bookmark's date first

The list is in diigo's updated order; each item now leads with its
updated_at as Date#toISOString() (diigo sends epoch seconds; updatedISO
converts, tested), or "(no date)".

Generated-by: Claude Opus 5.5
This commit is contained in:
dckc committed 2026-10-07 04:19:54 -05:00
1 parent 80c9279825
commit 860bbee2b5
4 files changed
+26 -3

No files matched your search

+4 -2
View File
@@ -15,7 +15,7 @@
import { WorkerEntrypoint } from "cloudflare:workers";
import { DiigoCache, PublicCache } from "./cache.js";
import type { Item } from "./cache.js";
import { usernameOf } from "./items.js";
import { updatedISO, usernameOf } from "./items.js";
import { toWebkey, idFromWebkey, isWebkey, shashKey } from "./webkeys.js";
import { pmSave } from "./pm-save.js";
@@ -457,7 +457,9 @@ ${items
const title = typeof it.title === "string" && it.title ? it.title : url;
const desc = typeof it.description === "string" && it.description ? `<br><small>${esc(it.description)}</small>` : "";
const href = /^https?:\/\//i.test(url) ? url : "#";
return `<li><a href="${esc(href)}">${esc(title)}</a>${desc}</li>`;
const when = updatedISO(it);
const date = when ? `<time datetime="${when}">${when}</time>` : "(no date)";
return `<li>${date} <a href="${esc(href)}">${esc(title)}</a>${desc}</li>`;
})
.join("\n")}
</ol>`;
+8
View File
@@ -64,3 +64,11 @@ export function usernameOf(item: Item | undefined): string {
export function publicOnly(rows: ItemRow[]): ItemRow[] {
return rows.filter((r) => !r.private);
}
/** when diigo last updated the item, as `Date#toISOString()`, or "" when
* it carries no usable `updated_at` (diigo sends epoch *seconds*) */
export function updatedISO(item: Item): string {
const secs = item.updated_at;
if (typeof secs !== "number" || !Number.isFinite(secs)) return "";
return new Date(secs * 1000).toISOString();
}