cleanup lastUpdateUtils from useless hardcoded things, in favor of new VCS system

This commit is contained in:
sebastien 2025-11-06 17:52:57 +01:00
parent 2a9e227378
commit 87291b3db4
4 changed files with 4 additions and 10 deletions

View File

@ -16,7 +16,7 @@ async function getRouteLastUpdatedAt(
vcs: Pick<VcsConfig, 'getFileLastUpdateInfo'>,
): Promise<number | null | undefined> {
// Important to bail-out early here
// This can lead to duplicated getLastUpdate() calls and performance problems
// This can lead to duplicated VCS calls and performance problems
// See https://github.com/facebook/docusaurus/pull/11211
if (route.metadata?.lastUpdatedAt === null) {
return null;

View File

@ -124,7 +124,6 @@ export {flattenRoutes} from './routeUtils';
export {
getGitLastUpdate,
getLastUpdate,
readLastUpdateData,
type LastUpdateData,
type FrontMatterLastUpdate,

View File

@ -13,6 +13,7 @@ import {
getFileCommitDate,
} from './vcs/gitUtils';
import {getDefaultVcsConfig} from './vcs/vcs';
import type {PluginOptions, VcsConfig} from '@docusaurus/types';
export type LastUpdateData = {
@ -72,12 +73,6 @@ export async function getGitLastUpdate(
}
}
export async function getLastUpdate(
filePath: string,
): Promise<LastUpdateData | null> {
return getGitLastUpdate(filePath);
}
type LastUpdateOptions = Pick<
PluginOptions,
'showLastUpdateAuthor' | 'showLastUpdateTime'

View File

@ -10,7 +10,7 @@ import {
getFileCommitDate,
GitNotFoundError,
} from './gitUtils';
import {getLastUpdate} from '../lastUpdateUtils';
import {getGitLastUpdate} from '../lastUpdateUtils';
import type {VcsConfig} from '@docusaurus/types';
/**
@ -52,7 +52,7 @@ export const VcsGitAdHoc: VcsConfig = {
// TODO non-ideal integration but good enough for now
// This keeps this new VscConfig system retro-compatible with the existing
// historical Docusaurus behavior based on Git
const result = await getLastUpdate(filePath);
const result = await getGitLastUpdate(filePath);
if (result === null) {
return null;
}