fix(mindspace): release edited public pages and fix achievements dates
Memind CI / Test, build, and release guards (push) Successful in 3m37s
Memind CI / Test, build, and release guards (push) Successful in 3m37s
Finish now releases static HTML delivery contracts in a finally block so re-edited pages are not stuck at HTTP 409, and M成果 groups pages by Asia/Shanghai calendar dates to avoid duplicate day headings. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -23,8 +23,24 @@ function formatDateTime(timestamp: number) {
|
||||
});
|
||||
}
|
||||
|
||||
const ACHIEVEMENTS_DATE_TIMEZONE = 'Asia/Shanghai';
|
||||
|
||||
function localCreatedDateKey(timestamp: number) {
|
||||
const parts = new Intl.DateTimeFormat('en-CA', {
|
||||
timeZone: ACHIEVEMENTS_DATE_TIMEZONE,
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
}).formatToParts(new Date(timestamp));
|
||||
const year = parts.find((part) => part.type === 'year')?.value ?? '0000';
|
||||
const month = parts.find((part) => part.type === 'month')?.value ?? '01';
|
||||
const day = parts.find((part) => part.type === 'day')?.value ?? '01';
|
||||
return `${year}-${month}-${day}`;
|
||||
}
|
||||
|
||||
function formatDateHeading(timestamp: number) {
|
||||
return new Date(timestamp).toLocaleDateString('zh-CN', {
|
||||
timeZone: ACHIEVEMENTS_DATE_TIMEZONE,
|
||||
year: 'numeric',
|
||||
month: 'long',
|
||||
day: 'numeric',
|
||||
@@ -45,7 +61,7 @@ function formatClickMetric(page: MindSpacePage) {
|
||||
function groupPagesByCreatedDate(pages: MindSpacePage[]) {
|
||||
const groups = new Map<string, MindSpacePage[]>();
|
||||
for (const page of pages) {
|
||||
const key = new Date(page.createdAt).toISOString().slice(0, 10);
|
||||
const key = localCreatedDateKey(page.createdAt);
|
||||
const bucket = groups.get(key);
|
||||
if (bucket) bucket.push(page);
|
||||
else groups.set(key, [page]);
|
||||
@@ -54,7 +70,7 @@ function groupPagesByCreatedDate(pages: MindSpacePage[]) {
|
||||
.sort(([left], [right]) => right.localeCompare(left))
|
||||
.map(([dateKey, items]) => ({
|
||||
dateKey,
|
||||
heading: formatDateHeading(items[0]?.createdAt ?? Date.parse(`${dateKey}T00:00:00`)),
|
||||
heading: formatDateHeading(items[0]?.createdAt ?? Date.parse(`${dateKey}T12:00:00+08:00`)),
|
||||
items,
|
||||
}));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user