mirror of
https://github.com/facebook/docusaurus.git
synced 2025-12-26 01:33:02 +00:00
wire VCS api in readLastUpdateData util
This commit is contained in:
parent
86b0d0e599
commit
48098cc3aa
|
|
@ -257,6 +257,7 @@ async function processBlogSourceFile(
|
|||
blogSourceAbsolute,
|
||||
options,
|
||||
frontMatter.last_update,
|
||||
vcs,
|
||||
);
|
||||
|
||||
const draft = isDraft({frontMatter});
|
||||
|
|
|
|||
|
|
@ -97,6 +97,7 @@ async function doProcessDocMetadata({
|
|||
siteDir,
|
||||
siteConfig: {
|
||||
markdown: {parseFrontMatter},
|
||||
future: {experimental_vcs: vcs},
|
||||
},
|
||||
} = context;
|
||||
|
||||
|
|
@ -125,6 +126,7 @@ async function doProcessDocMetadata({
|
|||
filePath,
|
||||
options,
|
||||
lastUpdateFrontMatter,
|
||||
vcs,
|
||||
);
|
||||
|
||||
// E.g. api/plugins/myDoc -> myDoc; myDoc -> myDoc
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
import * as path from 'path';
|
||||
import {fromPartial} from '@total-typescript/shoehorn';
|
||||
import {DEFAULT_PARSE_FRONT_MATTER} from '@docusaurus/utils/src';
|
||||
import {DEFAULT_VCS_CONFIG} from '@docusaurus/utils';
|
||||
import {readVersionsMetadata} from '../version';
|
||||
import {DEFAULT_OPTIONS} from '../../options';
|
||||
import {loadVersion} from '../loadVersion';
|
||||
|
|
@ -37,6 +38,9 @@ async function siteFixture(fixture: string) {
|
|||
markdown: {
|
||||
parseFrontMatter: DEFAULT_PARSE_FRONT_MATTER,
|
||||
},
|
||||
future: {
|
||||
experimental_vcs: DEFAULT_VCS_CONFIG,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -98,6 +98,7 @@ async function processPageSourceFile(
|
|||
): Promise<Metadata | undefined> {
|
||||
const {context, options, contentPaths} = params;
|
||||
const {siteConfig, baseUrl, siteDir, i18n} = context;
|
||||
const vcs = siteConfig.future.experimental_vcs;
|
||||
const {editUrl} = options;
|
||||
|
||||
// Lookup in localized folder in priority
|
||||
|
|
@ -180,6 +181,7 @@ async function processPageSourceFile(
|
|||
source,
|
||||
options,
|
||||
frontMatter.last_update,
|
||||
vcs,
|
||||
);
|
||||
|
||||
if (isDraft({frontMatter})) {
|
||||
|
|
|
|||
|
|
@ -116,13 +116,15 @@ export async function readLastUpdateData(
|
|||
filePath: string,
|
||||
options: LastUpdateOptions,
|
||||
lastUpdateFrontMatter: FrontMatterLastUpdate | undefined,
|
||||
|
||||
// We fallback to the default VSC config on purpose
|
||||
vcs: Pick<VcsConfig, 'getFileLastUpdateInfo'>,
|
||||
): Promise<LastUpdateData> {
|
||||
// We fallback to the default VSC config at runtime on purpose
|
||||
// It preserves retro-compatibility if a third-party plugin imports it
|
||||
// This also ensures unit tests keep working without extra setup
|
||||
// We still want to ensure type safety by requiring the VCS param
|
||||
// TODO Docusaurus v4: refactor all these Git read APIs
|
||||
vcs: Pick<VcsConfig, 'getFileLastUpdateInfo'> = DEFAULT_VCS_CONFIG,
|
||||
): Promise<LastUpdateData> {
|
||||
vcs = vcs ?? DEFAULT_VCS_CONFIG;
|
||||
|
||||
const {showLastUpdateAuthor, showLastUpdateTime} = options;
|
||||
|
||||
if (!showLastUpdateAuthor && !showLastUpdateTime) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue