Skip to content

Commit d98ef76

Browse files
committed
chore: update names
1 parent 772152c commit d98ef76

File tree

5 files changed

+15
-11
lines changed

5 files changed

+15
-11
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,4 @@ robots.txt
5656
# Crowdin report output
5757
src/data/crowdin/bucketsAwaitingReviewReport.csv
5858

59-
src/data/commit-history.json
59+
src/data/git-contributor-cache.json

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"dev": "yarn clean-commit-history && next dev",
77
"postinstall": "yarn theme",
88
"build": "yarn clean-commit-history && next build",
9-
"clean-commit-history": "touch ./src/data/commit-history.json && rm ./src/data/commit-history.json",
9+
"clean-commit-history": "touch ./src/data/git-contributor-cache.json && rm ./src/data/git-contributor-cache.json",
1010
"postbuild": "next-sitemap",
1111
"start": "next start",
1212
"lint": "next lint",

src/lib/api/fetchGitHistory.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { join } from "path"
44
import type { FileContributor } from "@/lib/types"
55

66
import {
7-
COMMIT_HISTORY_JSON,
87
CONTENT_DIR,
8+
GIT_CONTRIBUTOR_CACHE_JSON,
99
GITHUB_COMMITS_URL,
1010
OLD_CONTENT_DIR,
1111
} from "@/lib/constants"
@@ -49,11 +49,12 @@ async function fetchWithRateLimit(
4949
}
5050

5151
// Fetch commit history and save it to a JSON file
52-
export const fetchAndSaveGitHistory = async (mdDir: string) => {
52+
export const fetchAndCacheGitContributors = async (mdDir: string) => {
5353
const filepath = join("/", mdDir, "index.md")
5454

55-
const commitHistory = fs.existsSync(COMMIT_HISTORY_JSON)
56-
? JSON.parse(fs.readFileSync(COMMIT_HISTORY_JSON, "utf8"))
55+
// Load cache
56+
const commitHistory = fs.existsSync(GIT_CONTRIBUTOR_CACHE_JSON)
57+
? JSON.parse(fs.readFileSync(GIT_CONTRIBUTOR_CACHE_JSON, "utf8"))
5758
: {}
5859

5960
// First, check cache for existing commit history for English version (despite locale)
@@ -83,7 +84,10 @@ export const fetchAndSaveGitHistory = async (mdDir: string) => {
8384

8485
// Amend to commitHistory log and save
8586
commitHistory[filepath] = uniqueContributors
86-
fs.writeFileSync(COMMIT_HISTORY_JSON, JSON.stringify(commitHistory, null, 2))
87+
fs.writeFileSync(
88+
GIT_CONTRIBUTOR_CACHE_JSON,
89+
JSON.stringify(commitHistory, null, 2)
90+
)
8791

8892
return uniqueContributors
8993
}

src/lib/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,4 +150,4 @@ export const HAMBURGER_BUTTON_ID = "mobile-menu-button"
150150
export const MOBILE_LANGUAGE_BUTTON_NAME = "mobile-language-button"
151151
export const DESKTOP_LANGUAGE_BUTTON_NAME = "desktop-language-button"
152152

153-
export const COMMIT_HISTORY_JSON = "src/data/commit-history.json"
153+
export const GIT_CONTRIBUTOR_CACHE_JSON = "src/data/git-contributor-cache.json"

src/pages/[...slug].tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ import {
5555
UseCasesLayout,
5656
} from "@/layouts"
5757
import { fetchGFIs } from "@/lib/api/fetchGFIs"
58-
import { fetchAndSaveGitHistory } from "@/lib/api/fetchGitHistory"
58+
import { fetchAndCacheGitContributors } from "@/lib/api/fetchGitHistory"
5959
import rehypeHeadingIds from "@/lib/rehype/rehypeHeadingIds"
6060
import rehypeImg from "@/lib/rehype/rehypeImg"
6161
import remarkInferToc from "@/lib/rehype/remarkInferToc"
@@ -181,7 +181,7 @@ export const getStaticProps = (async (context) => {
181181

182182
const gfissues = await gfIssuesDataFetch()
183183

184-
const contributors = await fetchAndSaveGitHistory(mdDir)
184+
const gitContributors = await fetchAndCacheGitContributors(mdDir)
185185

186186
return {
187187
props: {
@@ -197,7 +197,7 @@ export const getStaticProps = (async (context) => {
197197
tocItems,
198198
crowdinContributors,
199199
gfissues,
200-
contributors,
200+
contributors: gitContributors,
201201
},
202202
}
203203
}) satisfies GetStaticProps<Props, Params>

0 commit comments

Comments
 (0)