diff --git a/web/src/components/CalendarView/dayModel.ts b/web/src/components/CalendarView/dayModel.ts
index 74384ac73..69948f265 100644
--- a/web/src/components/CalendarView/dayModel.ts
+++ b/web/src/components/CalendarView/dayModel.ts
@@ -19,6 +19,8 @@ import { classifyManagedAttachmentImageURL, extractAttachmentUIDFromName } from
export interface CalendarDayExcerpt {
memoName: string;
+ /** The memo's creator, so a mixed-author scope can attribute the preview. */
+ creator: string;
text: string;
isCode: boolean;
}
@@ -31,6 +33,8 @@ export interface CalendarDayImage {
export interface CalendarDaySummary {
/** Every memo, including hidden ones, in chronological order for the day panel. */
memos: Memo[];
+ /** Each creator once, in the order they first wrote that day; a hidden memo still names its author. */
+ creators: string[];
excerpt?: CalendarDayExcerpt;
/** At most one image per memo, from the first two eligible image-bearing memos. */
images: CalendarDayImage[];
@@ -61,7 +65,12 @@ const getExcerpt = (memo: Memo, tree: Root): CalendarDayExcerpt | undefined => {
.join("\n")
.trim() || (!memo.content.trim() ? memo.snippet.trim() : "");
if (!text) return undefined;
- return { memoName: memo.name, text: text.length > 280 ? `${text.slice(0, 280).trimEnd()}…` : text, isCode: readable[0]?.isCode ?? false };
+ return {
+ memoName: memo.name,
+ creator: memo.creator,
+ text: text.length > 280 ? `${text.slice(0, 280).trimEnd()}…` : text,
+ isCode: readable[0]?.isCode ?? false,
+ };
};
// Resolve reference-style images and apply the same src sanitization as the body renderer.
@@ -102,6 +111,17 @@ const getImageCandidates = (memo: Memo, tree: Root): string[] => {
return candidates;
};
+const parseMarkdown = (content: string): Root => fromMarkdown(content, { extensions: [gfm()], mdastExtensions: [gfmFromMarkdown()] });
+
+/**
+ * The thumbnail of a memo's first photo, chosen the way a calendar day chooses its photos:
+ * Markdown images in reading order, then image attachments. Content with neither is not parsed.
+ */
+export const getMemoThumbnail = (memo: Memo): string | undefined => {
+ if (!memo.content.includes("![") && !memo.attachments.some((attachment) => isImage(attachment.type))) return undefined;
+ return getImageCandidates(memo, parseMarkdown(memo.content))[0];
+};
+
/** Fold the month into stable day snapshots, independent of API pagination/order. */
export const buildCalendarMonthModel = (
memos: Memo[],
@@ -117,17 +137,15 @@ export const buildCalendarMonthModel = (
const fileFallbacks = new Map {t(filters.length ? "map.no-results-hint" : "map.empty-hint")} {t(filters.length ? "map.no-results-hint" : "map.empty-hint")}{t(filters.length ? "map.no-results" : "map.empty")}
-