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",