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 <noreply@anthropic.com>
This commit is contained in:
Ricardo
2026-02-07 12:48:29 +01:00
parent fb6e92b2be
commit d45d183024
3 changed files with 20 additions and 3 deletions
+11 -1
View File
@@ -16,7 +16,7 @@ async function get(request, response) {
const { application } = request.app.locals; const { application } = request.app.locals;
try { try {
const [sources, blogs, blogCount, itemCount, syncStatus] = await Promise.all([ const [rawSources, blogs, blogCount, itemCount, syncStatus] = await Promise.all([
getSources(application), getSources(application),
getBlogs(application, { limit: 10 }), getBlogs(application, { limit: 10 }),
countBlogs(application), countBlogs(application),
@@ -24,6 +24,16 @@ async function get(request, response) {
getSyncStatus(application), 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 // Get blogs with errors
const errorBlogs = await getBlogs(application, { includeHidden: true, limit: 100 }); const errorBlogs = await getBlogs(application, { includeHidden: true, limit: 100 });
const blogsWithErrors = errorBlogs.filter((b) => b.status === "error"); const blogsWithErrors = errorBlogs.filter((b) => b.status === "error");
+8 -1
View File
@@ -150,12 +150,19 @@ export async function getSyncStatus(application) {
db.collection("blogrollMeta").findOne({ key: "syncStats" }), 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 { return {
status: "ok", status: "ok",
isRunning, isRunning,
blogs: { count: blogCount }, blogs: { count: blogCount },
items: { count: itemCount }, items: { count: itemCount },
lastSync: syncStats?.lastFullSync || null, lastSync,
lastSyncStats: syncStats || null, lastSyncStats: syncStats || null,
}; };
} }
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@rmdes/indiekit-endpoint-blogroll", "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.", "description": "Blogroll endpoint for Indiekit. Aggregates blog feeds from OPML, JSON feeds, or manual entry.",
"keywords": [ "keywords": [
"indiekit", "indiekit",