export type CommitResponse = Array<{ sha: string; html_url: string; commit: { message: string; author: { name: string; date: string; }; }; }>; /** Format an ISO timestamp in UTC. */ export function formatDate(value: string | undefined): string { if (!value) return "—"; const date = new Date(value); if (Number.isNaN(date.getTime())) return value; return date.toLocaleString("en-US", { dateStyle: "medium", timeStyle: "short", timeZone: "UTC", }) + " UTC"; } /** Render public repository commits returned by the GitHub API. */ export function renderGithubCommits( commitList: CommitResponse | undefined, ) { if (!commitList || commitList.length === 0) { return (
No commits found
); } return (
{commitList.slice(0, 20).map((commit) => (
{commit.commit.message.split("\n")[0]}
{commit.commit.author.name} • {formatDate( commit.commit.author.date, )}
View commit →
))}
); }