diff --git a/.changeset/flat-crabs-thank.md b/.changeset/flat-crabs-thank.md new file mode 100644 index 0000000000..8f4f709779 --- /dev/null +++ b/.changeset/flat-crabs-thank.md @@ -0,0 +1,5 @@ +--- +'nextra': patch +--- + +fix: print shallow warning only once diff --git a/packages/nextra/src/loader.ts b/packages/nextra/src/loader.ts index 66624ce9e4..4b596a010a 100644 --- a/packages/nextra/src/loader.ts +++ b/packages/nextra/src/loader.ts @@ -18,6 +18,8 @@ const indexContentEmitted = new Set() const pagesDir = path.resolve(findPagesDir()) +let wasShallowWarningPrinted = false + const [repository, gitRoot] = (function () { try { const repo = Repository.discover(process.cwd()) @@ -143,7 +145,7 @@ async function loader( let timestamp: number | undefined if (repository && gitRoot) { - if (repository.isShallow()) { + if (repository.isShallow() && !wasShallowWarningPrinted) { if (process.env.VERCEL) { console.warn( '[nextra] The repository is shallow cloned, so the latest modified time will not be presented. Set the VERCEL_DEEP_CLONE=true environment variable to enable deep cloning.' @@ -157,6 +159,7 @@ async function loader( '[nextra] The repository is shallow cloned, so the latest modified time will not be presented.' ) } + wasShallowWarningPrinted = true } try { timestamp = await repository.getFileLatestModifiedDateAsync(