Anchor calendar previews to each client historical editorial line.
Remix same-month prior years and recurring series instead of generic season placeholders like Black Friday. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -46,7 +46,7 @@ export async function POST(req: NextRequest) {
|
||||
const docs = await restGet<{ content?: unknown }[]>(
|
||||
`/rest/v1/documents?tenant_id=eq.${encodeURIComponent(
|
||||
ctx.tenantId
|
||||
)}&type=eq.calendar&select=content&order=created_at.desc&limit=24`
|
||||
)}&type=eq.calendar&select=content&order=created_at.desc&limit=48`
|
||||
);
|
||||
const history: RrssMonthPlan[] = [];
|
||||
for (const d of docs.data || []) {
|
||||
@@ -55,6 +55,14 @@ export async function POST(req: NextRequest) {
|
||||
history.push(plan as unknown as RrssMonthPlan);
|
||||
}
|
||||
}
|
||||
// Prefer same calendar month from prior years first (e.g. 2025-11 before 2026-10)
|
||||
const mm = month.slice(5, 7);
|
||||
history.sort((a, b) => {
|
||||
const aSame = a.month.slice(5, 7) === mm ? 0 : 1;
|
||||
const bSame = b.month.slice(5, 7) === mm ? 0 : 1;
|
||||
if (aSame !== bSame) return aSame - bSame;
|
||||
return String(b.month).localeCompare(String(a.month));
|
||||
});
|
||||
|
||||
const result = await generateMonthPreview({
|
||||
ym: month,
|
||||
|
||||
Reference in New Issue
Block a user