fix: add npmPublishedAt to API response and add null safety for dates
This commit is contained in:
parent
ad694e27e1
commit
6ccb5fbd79
3 changed files with 10 additions and 4 deletions
1
apps/web/.gitignore
vendored
1
apps/web/.gitignore
vendored
|
|
@ -1 +1,2 @@
|
||||||
.vercel
|
.vercel
|
||||||
|
.env*.local
|
||||||
|
|
|
||||||
|
|
@ -301,6 +301,7 @@ export async function GET(request: NextRequest) {
|
||||||
npmHomepage: true,
|
npmHomepage: true,
|
||||||
npmLicense: true,
|
npmLicense: true,
|
||||||
npmKeywords: true,
|
npmKeywords: true,
|
||||||
|
npmPublishedAt: true,
|
||||||
category: true,
|
category: true,
|
||||||
env: true,
|
env: true,
|
||||||
frameworks: true,
|
frameworks: true,
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,9 @@ function sortTools(tools: Tool[], sortBy: SortOption): Tool[] {
|
||||||
return bDownloads - aDownloads;
|
return bDownloads - aDownloads;
|
||||||
}
|
}
|
||||||
// Sort by recent (createdAt descending)
|
// Sort by recent (createdAt descending)
|
||||||
return new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime();
|
const aTime = a.createdAt ? new Date(a.createdAt).getTime() : 0;
|
||||||
|
const bTime = b.createdAt ? new Date(b.createdAt).getTime() : 0;
|
||||||
|
return bTime - aTime;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -336,9 +338,11 @@ export default function ToolSearchPage(): React.ReactElement {
|
||||||
showCopy={true}
|
showCopy={true}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="text-xs text-foreground-tertiary">
|
{tool.package.npmPublishedAt && (
|
||||||
Published {formatTimeAgo(tool.package.npmPublishedAt)}
|
<div className="text-xs text-foreground-tertiary">
|
||||||
</div>
|
Published {formatTimeAgo(tool.package.npmPublishedAt)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue