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

View File

@@ -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");

View File

@@ -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,
};
}

View File

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