diff --git a/packages/docusaurus-plugin-content-docs/package.json b/packages/docusaurus-plugin-content-docs/package.json index 7f774c607076..b974dfcb2ffe 100644 --- a/packages/docusaurus-plugin-content-docs/package.json +++ b/packages/docusaurus-plugin-content-docs/package.json @@ -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", diff --git a/packages/docusaurus-plugin-content-docs/src/server/index.ts b/packages/docusaurus-plugin-content-docs/src/server/index.ts new file mode 100644 index 000000000000..1be860cedebb --- /dev/null +++ b/packages/docusaurus-plugin-content-docs/src/server/index.ts @@ -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'; diff --git a/packages/docusaurus-plugin-content-docs/src/versions.ts b/packages/docusaurus-plugin-content-docs/src/versions.ts index 7934a4e0b725..3a617d0df099 100644 --- a/packages/docusaurus-plugin-content-docs/src/versions.ts +++ b/packages/docusaurus-plugin-content-docs/src/versions.ts @@ -87,7 +87,7 @@ function ensureValidVersionArray( versionArray.forEach(ensureValidVersionString); } -async function readVersionsFile( +export async function readVersionsFile( siteDir: string, pluginId: string, ): Promise { @@ -101,7 +101,7 @@ async function readVersionsFile( } } -async function readVersionNames( +export async function readVersionNames( siteDir: string, options: Pick< PluginOptions, @@ -260,7 +260,7 @@ function getVersionEditUrls({ }; } -function getDefaultVersionBanner({ +export function getDefaultVersionBanner({ versionName, versionNames, lastVersionName, @@ -285,7 +285,7 @@ function getDefaultVersionBanner({ } } -function getVersionBanner({ +export function getVersionBanner({ versionName, versionNames, lastVersionName, @@ -307,7 +307,7 @@ function getVersionBanner({ }); } -function getVersionBadge({ +export function getVersionBadge({ versionName, versionNames, options, @@ -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, -) { +): string[] { if (options.onlyIncludeVersions) { return versionNamesUnfiltered.filter((name) => (options.onlyIncludeVersions || []).includes(name),