Skip to content

Commit 0257a06

Browse files
committed
update contributors fetching logic
1 parent a9152e4 commit 0257a06

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/lib/utils/contributors.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,26 @@ export const getPageContributorInfo = async (
4949
locale: Lang,
5050
cache: CommitHistory
5151
) => {
52-
const gitContributors = await fetchAndCacheGitContributors(
53-
join("src/pages/[locale]", pagePath),
54-
cache
52+
const gitContributors = [
53+
...(await fetchAndCacheGitContributors(
54+
join("src/pages/[locale]", pagePath),
55+
cache
56+
)),
57+
...(await fetchAndCacheGitContributors(join("src/pages", pagePath), cache)),
58+
]
59+
60+
const uniqueGitContributors = gitContributors.filter(
61+
(contributor, index, self) =>
62+
index === self.findIndex((t) => t.login === contributor.login)
5563
)
5664

5765
const latestCommitDate = getLastModifiedDate(pagePath, locale!)
58-
const gitHubLastEdit = gitContributors[0]?.date
66+
const gitHubLastEdit = uniqueGitContributors[0]?.date
5967

6068
const lastEditLocaleTimestamp = getLocaleTimestamp(
6169
locale,
6270
gitHubLastEdit || latestCommitDate
6371
)
6472

65-
return { contributors: gitContributors, lastEditLocaleTimestamp }
73+
return { contributors: uniqueGitContributors, lastEditLocaleTimestamp }
6674
}

0 commit comments

Comments
 (0)