From d45d18302450c51b4d7a84706c53bd5f4a0d6d0c Mon Sep 17 00:00:00 2001 From: Ricardo Date: Sat, 7 Feb 2026 12:48:29 +0100 Subject: [PATCH] fix: convert Date objects to ISO strings for template compatibility The Indiekit date filter expects ISO strings, not JavaScript Date objects. This fixes 'dateString.split is not a function' errors in the dashboard. Co-Authored-By: Claude Opus 4.5 --- lib/controllers/dashboard.js | 12 +++++++++++- lib/sync/scheduler.js | 9 ++++++++- package.json | 2 +- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/lib/controllers/dashboard.js b/lib/controllers/dashboard.js index bf4a309..1cfddb0 100644 --- a/lib/controllers/dashboard.js +++ b/lib/controllers/dashboard.js @@ -16,7 +16,7 @@ async function get(request, response) { const { application } = request.app.locals; try { - const [sources, blogs, blogCount, itemCount, syncStatus] = await Promise.all([ + const [rawSources, blogs, blogCount, itemCount, syncStatus] = await Promise.all([ getSources(application), getBlogs(application, { limit: 10 }), countBlogs(application), @@ -24,6 +24,16 @@ async function get(request, response) { getSyncStatus(application), ]); + // Convert Date objects to ISO strings for template date filter compatibility + const sources = rawSources.map((source) => ({ + ...source, + lastSyncAt: source.lastSyncAt + ? (source.lastSyncAt instanceof Date + ? source.lastSyncAt.toISOString() + : source.lastSyncAt) + : null, + })); + // Get blogs with errors const errorBlogs = await getBlogs(application, { includeHidden: true, limit: 100 }); const blogsWithErrors = errorBlogs.filter((b) => b.status === "error"); diff --git a/lib/sync/scheduler.js b/lib/sync/scheduler.js index d1a9646..5b222d8 100644 --- a/lib/sync/scheduler.js +++ b/lib/sync/scheduler.js @@ -150,12 +150,19 @@ export async function getSyncStatus(application) { db.collection("blogrollMeta").findOne({ key: "syncStats" }), ]); + // Convert Date to ISO string for template date filter compatibility + const lastSync = syncStats?.lastFullSync + ? (syncStats.lastFullSync instanceof Date + ? syncStats.lastFullSync.toISOString() + : syncStats.lastFullSync) + : null; + return { status: "ok", isRunning, blogs: { count: blogCount }, items: { count: itemCount }, - lastSync: syncStats?.lastFullSync || null, + lastSync, lastSyncStats: syncStats || null, }; } diff --git a/package.json b/package.json index 134e565..f0253b0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@rmdes/indiekit-endpoint-blogroll", - "version": "1.0.2", + "version": "1.0.3", "description": "Blogroll endpoint for Indiekit. Aggregates blog feeds from OPML, JSON feeds, or manual entry.", "keywords": [ "indiekit",