From d32904e44fc65d680b5564b2642c35156295aaa4 Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Wed, 26 Jan 2022 16:46:23 -0800 Subject: [PATCH 1/5] Add exports. --- packages/docusaurus-plugin-content-docs/package.json | 1 + .../docusaurus-plugin-content-docs/src/versions.ts | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/docusaurus-plugin-content-docs/package.json b/packages/docusaurus-plugin-content-docs/package.json index 7f774c607076..9e7c3c0313be 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", + "./versions": "./lib/versions.js", ".": "./lib/index.js" }, "types": "src/plugin-content-docs.d.ts", diff --git a/packages/docusaurus-plugin-content-docs/src/versions.ts b/packages/docusaurus-plugin-content-docs/src/versions.ts index 7934a4e0b725..b037cdf39846 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, @@ -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), From 00fb640ddfac2aa2bae3e8b382c0e1757d68fb8f Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Wed, 26 Jan 2022 16:47:57 -0800 Subject: [PATCH 2/5] Export constants. --- packages/docusaurus-plugin-content-docs/src/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/docusaurus-plugin-content-docs/src/index.ts b/packages/docusaurus-plugin-content-docs/src/index.ts index f15f0ca72985..9d8042c60df1 100644 --- a/packages/docusaurus-plugin-content-docs/src/index.ts +++ b/packages/docusaurus-plugin-content-docs/src/index.ts @@ -391,3 +391,4 @@ export default async function pluginContentDocs( } export {validateOptions} from './options'; +export * from './constants'; From 98084afe51c264ad51771614b6ea1e06d25afcf4 Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Thu, 27 Jan 2022 16:04:22 -0800 Subject: [PATCH 3/5] Add node entry. --- packages/docusaurus-plugin-content-docs/package.json | 2 +- packages/docusaurus-plugin-content-docs/src/index.ts | 1 - .../docusaurus-plugin-content-docs/src/node/index.ts | 10 ++++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 packages/docusaurus-plugin-content-docs/src/node/index.ts diff --git a/packages/docusaurus-plugin-content-docs/package.json b/packages/docusaurus-plugin-content-docs/package.json index 9e7c3c0313be..d173d734b127 100644 --- a/packages/docusaurus-plugin-content-docs/package.json +++ b/packages/docusaurus-plugin-content-docs/package.json @@ -5,7 +5,7 @@ "main": "lib/index.js", "exports": { "./client": "./lib/client/index.js", - "./versions": "./lib/versions.js", + "./node": "./lib/node/index.js", ".": "./lib/index.js" }, "types": "src/plugin-content-docs.d.ts", diff --git a/packages/docusaurus-plugin-content-docs/src/index.ts b/packages/docusaurus-plugin-content-docs/src/index.ts index 9d8042c60df1..f15f0ca72985 100644 --- a/packages/docusaurus-plugin-content-docs/src/index.ts +++ b/packages/docusaurus-plugin-content-docs/src/index.ts @@ -391,4 +391,3 @@ export default async function pluginContentDocs( } export {validateOptions} from './options'; -export * from './constants'; diff --git a/packages/docusaurus-plugin-content-docs/src/node/index.ts b/packages/docusaurus-plugin-content-docs/src/node/index.ts new file mode 100644 index 000000000000..2bfa7559246d --- /dev/null +++ b/packages/docusaurus-plugin-content-docs/src/node/index.ts @@ -0,0 +1,10 @@ +/** + * 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 * from '../versions'; From 0b2230d27c0b90cbe4026aaffcacce58b8d91c9f Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Fri, 28 Jan 2022 16:24:04 -0800 Subject: [PATCH 4/5] Rename to server. --- packages/docusaurus-plugin-content-docs/package.json | 2 +- .../src/{node => server}/index.ts | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename packages/docusaurus-plugin-content-docs/src/{node => server}/index.ts (100%) diff --git a/packages/docusaurus-plugin-content-docs/package.json b/packages/docusaurus-plugin-content-docs/package.json index d173d734b127..b974dfcb2ffe 100644 --- a/packages/docusaurus-plugin-content-docs/package.json +++ b/packages/docusaurus-plugin-content-docs/package.json @@ -5,7 +5,7 @@ "main": "lib/index.js", "exports": { "./client": "./lib/client/index.js", - "./node": "./lib/node/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/node/index.ts b/packages/docusaurus-plugin-content-docs/src/server/index.ts similarity index 100% rename from packages/docusaurus-plugin-content-docs/src/node/index.ts rename to packages/docusaurus-plugin-content-docs/src/server/index.ts From e111ef40a2620de521cc754df9840c31a2da45d7 Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Fri, 28 Jan 2022 16:28:51 -0800 Subject: [PATCH 5/5] Only export certain names. --- .../src/server/index.ts | 11 ++++++++++- .../docusaurus-plugin-content-docs/src/versions.ts | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/docusaurus-plugin-content-docs/src/server/index.ts b/packages/docusaurus-plugin-content-docs/src/server/index.ts index 2bfa7559246d..1be860cedebb 100644 --- a/packages/docusaurus-plugin-content-docs/src/server/index.ts +++ b/packages/docusaurus-plugin-content-docs/src/server/index.ts @@ -7,4 +7,13 @@ // APIs available to Node.js export * from '../constants'; -export * from '../versions'; + +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 b037cdf39846..3a617d0df099 100644 --- a/packages/docusaurus-plugin-content-docs/src/versions.ts +++ b/packages/docusaurus-plugin-content-docs/src/versions.ts @@ -307,7 +307,7 @@ export function getVersionBanner({ }); } -function getVersionBadge({ +export function getVersionBadge({ versionName, versionNames, options,