Skip to content

Commit 3d36fc5

Browse files
myelinated-wackerowclaudewackerow
committed
fix: hide epoch date when contributors missing
getAppPageLastCommitDate reduced an empty contributors array to new Date(0), so app pages with no contributor data rendered "Page last update: January 1, 1970". It now returns "" for empty input, and getAppPageContributorInfo guards the format call so the timestamp stays empty rather than formatting an Invalid Date. Empty is falsy, so FileContributors hides the "last update" line via its existing guard, and the page JSON-LD emits an empty dateModified instead of the epoch. Returning "" keeps the type string, avoiding a change across the ~15 consumers that type the field as string. The data-side root cause (the fetcher writing empty arrays on GitHub secondary rate limits) was fixed in #18073; this is the UI-side defensive complement and supersedes #18071. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Co-Authored-By: wackerow <54227730+wackerow@users.noreply.github.com>
1 parent 1a05dbe commit 3d36fc5

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

src/lib/utils/contributors.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ export const getAppPageContributorInfo = async (
6363
)
6464

6565
const latestCommitDate = getAppPageLastCommitDate(gitHubContributors)
66-
const lastEditLocaleTimestamp = getLocaleTimestamp(locale, latestCommitDate)
66+
// Guard the empty sentinel: getLocaleTimestamp(locale, "") would format an
67+
// Invalid Date, so keep the timestamp empty when there is no commit date.
68+
const lastEditLocaleTimestamp = latestCommitDate
69+
? getLocaleTimestamp(locale, latestCommitDate)
70+
: ""
6771

6872
// if (
6973
// (!uniqueGitHubContributors.length || !lastEditLocaleTimestamp) &&

src/lib/utils/gh.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
import type { FileContributor } from "../types"
22

3+
// Returns "" (not the Unix epoch) for an empty array, so callers can hide
4+
// the "last update" line instead of formatting "January 1, 1970".
35
export const getAppPageLastCommitDate = (
46
gitHubContributors: FileContributor[]
5-
) =>
6-
gitHubContributors
7+
): string => {
8+
if (!gitHubContributors.length) return ""
9+
10+
return gitHubContributors
711
.reduce((latest, contributor) => {
812
const commitDate = new Date(contributor.date)
913
return commitDate > latest ? commitDate : latest
1014
}, new Date(0))
1115
.toString()
16+
}
1217

1318
const LABELS_TO_SEARCH = [
1419
"content",

0 commit comments

Comments
 (0)