mirror of
https://github.com/netbirdio/docs.git
synced 2026-10-05 05:09:05 +02:00
perf: build git last-modified map in one pass instead of per-file (#837)
Replace ~314 `git log` spawns per gen script with a single `git log --name-only` pass, memoised per process. Cuts gen:last-updated + gen:sitemap from ~15s to ~1.5s. Output is byte-identical to the per-file version; still degrades to no-dates when git is unavailable (e.g. the Docker image).
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import { fileURLToPath } from 'url'
|
||||
import { getGitLastModified } from './git-dates.mjs'
|
||||
import { buildGitDateMap } from './git-dates.mjs'
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
||||
const ROOT = path.join(__dirname, '..')
|
||||
@@ -56,10 +56,11 @@ function escapeXml(s) {
|
||||
.replace(/'/g, ''')
|
||||
}
|
||||
|
||||
const gitDates = buildGitDateMap()
|
||||
const entries = findMdxFiles(PAGES_DIR)
|
||||
.map(({ route, filePath }) => ({
|
||||
url: toPublicUrl(route),
|
||||
lastmod: getGitLastModified(filePath),
|
||||
lastmod: gitDates.get(path.relative(ROOT, filePath)) ?? null,
|
||||
}))
|
||||
.sort((a, b) => a.url.localeCompare(b.url))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user