Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(content-docs): export versioning utils #6477

Merged
merged 5 commits into from
Feb 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/docusaurus-plugin-content-docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"main": "lib/index.js",
"exports": {
"./client": "./lib/client/index.js",
"./server": "./lib/server/index.js",
".": "./lib/index.js"
},
"types": "src/plugin-content-docs.d.ts",
Expand Down
19 changes: 19 additions & 0 deletions packages/docusaurus-plugin-content-docs/src/server/index.ts
Original file line number Diff line number Diff line change
@@ -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';
14 changes: 7 additions & 7 deletions packages/docusaurus-plugin-content-docs/src/versions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function ensureValidVersionArray(
versionArray.forEach(ensureValidVersionString);
}

async function readVersionsFile(
export async function readVersionsFile(
siteDir: string,
pluginId: string,
): Promise<string[] | null> {
Expand All @@ -101,7 +101,7 @@ async function readVersionsFile(
}
}

async function readVersionNames(
export async function readVersionNames(
siteDir: string,
options: Pick<
PluginOptions,
Expand Down Expand Up @@ -260,7 +260,7 @@ function getVersionEditUrls({
};
}

function getDefaultVersionBanner({
export function getDefaultVersionBanner({
versionName,
versionNames,
lastVersionName,
Expand All @@ -285,7 +285,7 @@ function getDefaultVersionBanner({
}
}

function getVersionBanner({
export function getVersionBanner({
versionName,
versionNames,
lastVersionName,
Expand All @@ -307,7 +307,7 @@ function getVersionBanner({
});
}

function getVersionBadge({
export function getVersionBadge({
versionName,
versionNames,
options,
Expand Down Expand Up @@ -536,10 +536,10 @@ function checkVersionsOptions(
* Note: we preserve the order in which versions are provided;
* the order of the onlyIncludeVersions array does not matter
*/
function filterVersions(
export function filterVersions(
versionNamesUnfiltered: string[],
options: Pick<PluginOptions, 'onlyIncludeVersions'>,
) {
): string[] {
if (options.onlyIncludeVersions) {
return versionNamesUnfiltered.filter((name) =>
(options.onlyIncludeVersions || []).includes(name),
Expand Down