mirror of
https://github.com/svemagie/indiekit-endpoint-blogroll.git
synced 2026-04-02 15:34:59 +02:00
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:
@@ -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");
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user