mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-16 10:37:20 +02:00
fix(content-docs): export versioning utils (#6477)
This commit is contained in:
parent
3573b5e4a9
commit
65ba551f5b
3 changed files with 27 additions and 7 deletions
|
@ -5,6 +5,7 @@
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"exports": {
|
"exports": {
|
||||||
"./client": "./lib/client/index.js",
|
"./client": "./lib/client/index.js",
|
||||||
|
"./server": "./lib/server/index.js",
|
||||||
".": "./lib/index.js"
|
".": "./lib/index.js"
|
||||||
},
|
},
|
||||||
"types": "src/plugin-content-docs.d.ts",
|
"types": "src/plugin-content-docs.d.ts",
|
||||||
|
|
19
packages/docusaurus-plugin-content-docs/src/server/index.ts
Normal file
19
packages/docusaurus-plugin-content-docs/src/server/index.ts
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
/**
|
||||||
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// APIs available to Node.js
|
||||||
|
export * from '../constants';
|
||||||
|
|
||||||
|
export {
|
||||||
|
filterVersions,
|
||||||
|
getDefaultVersionBanner,
|
||||||
|
getVersionBadge,
|
||||||
|
getVersionBanner,
|
||||||
|
getVersionsFilePath,
|
||||||
|
readVersionsFile,
|
||||||
|
readVersionNames,
|
||||||
|
} from '../versions';
|
|
@ -85,7 +85,7 @@ function ensureValidVersionArray(
|
||||||
versionArray.forEach(ensureValidVersionString);
|
versionArray.forEach(ensureValidVersionString);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function readVersionsFile(
|
export async function readVersionsFile(
|
||||||
siteDir: string,
|
siteDir: string,
|
||||||
pluginId: string,
|
pluginId: string,
|
||||||
): Promise<string[] | null> {
|
): Promise<string[] | null> {
|
||||||
|
@ -98,7 +98,7 @@ async function readVersionsFile(
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function readVersionNames(
|
export async function readVersionNames(
|
||||||
siteDir: string,
|
siteDir: string,
|
||||||
options: Pick<
|
options: Pick<
|
||||||
PluginOptions,
|
PluginOptions,
|
||||||
|
@ -257,7 +257,7 @@ function getVersionEditUrls({
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDefaultVersionBanner({
|
export function getDefaultVersionBanner({
|
||||||
versionName,
|
versionName,
|
||||||
versionNames,
|
versionNames,
|
||||||
lastVersionName,
|
lastVersionName,
|
||||||
|
@ -280,7 +280,7 @@ function getDefaultVersionBanner({
|
||||||
return 'unmaintained';
|
return 'unmaintained';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getVersionBanner({
|
export function getVersionBanner({
|
||||||
versionName,
|
versionName,
|
||||||
versionNames,
|
versionNames,
|
||||||
lastVersionName,
|
lastVersionName,
|
||||||
|
@ -302,7 +302,7 @@ function getVersionBanner({
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getVersionBadge({
|
export function getVersionBadge({
|
||||||
versionName,
|
versionName,
|
||||||
versionNames,
|
versionNames,
|
||||||
options,
|
options,
|
||||||
|
@ -531,10 +531,10 @@ function checkVersionsOptions(
|
||||||
* Note: we preserve the order in which versions are provided;
|
* Note: we preserve the order in which versions are provided;
|
||||||
* the order of the onlyIncludeVersions array does not matter
|
* the order of the onlyIncludeVersions array does not matter
|
||||||
*/
|
*/
|
||||||
function filterVersions(
|
export function filterVersions(
|
||||||
versionNamesUnfiltered: string[],
|
versionNamesUnfiltered: string[],
|
||||||
options: Pick<PluginOptions, 'onlyIncludeVersions'>,
|
options: Pick<PluginOptions, 'onlyIncludeVersions'>,
|
||||||
) {
|
): string[] {
|
||||||
if (options.onlyIncludeVersions) {
|
if (options.onlyIncludeVersions) {
|
||||||
return versionNamesUnfiltered.filter((name) =>
|
return versionNamesUnfiltered.filter((name) =>
|
||||||
(options.onlyIncludeVersions || []).includes(name),
|
(options.onlyIncludeVersions || []).includes(name),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue