From 221daf499a64aa5d821519b1b89f4b4f8785d68b Mon Sep 17 00:00:00 2001 From: sebastien Date: Fri, 23 Oct 2026 18:14:46 +0200 Subject: [PATCH 1/8] feat(docs): export the SidebarItemConfig and SidebarItemCategoryConfig types (AI-assisted) The dogfooding sidebars imported them from the lib/sidebars/types deep import. Co-Authored-By: Claude Opus 5.5 --- .../src/plugin-content-docs.d.ts | 3 +++ website/_dogfooding/docs-tests-sidebars.js | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/docusaurus-plugin-content-docs/src/plugin-content-docs.d.ts b/packages/docusaurus-plugin-content-docs/src/plugin-content-docs.d.ts index 766a7469ab4a..ad15d762a99e 100644 --- a/packages/docusaurus-plugin-content-docs/src/plugin-content-docs.d.ts +++ b/packages/docusaurus-plugin-content-docs/src/plugin-content-docs.d.ts @@ -246,6 +246,9 @@ declare module '@docusaurus/plugin-content-docs' { > >; export type SidebarsConfig = import('./sidebars/types').SidebarsConfig; + export type SidebarItemConfig = import('./sidebars/types').SidebarItemConfig; + export type SidebarItemCategoryConfig = + import('./sidebars/types').SidebarItemCategoryConfig; export type VersionMetadata = ContentPaths & { /** A name like `1.0.0`. Acquired from `versions.json`. */ diff --git a/website/_dogfooding/docs-tests-sidebars.js b/website/_dogfooding/docs-tests-sidebars.js index da20f4e6a9b7..bd4a738da042 100644 --- a/website/_dogfooding/docs-tests-sidebars.js +++ b/website/_dogfooding/docs-tests-sidebars.js @@ -7,8 +7,8 @@ /** * @typedef {import('@docusaurus/plugin-content-docs').SidebarsConfig} SidebarsConfig - * @typedef {import('@docusaurus/plugin-content-docs/lib/sidebars/types').SidebarItemConfig} SidebarItemConfig - * @typedef {import('@docusaurus/plugin-content-docs/lib/sidebars/types').SidebarItemCategoryConfig} SidebarItemCategoryConfig + * @typedef {import('@docusaurus/plugin-content-docs').SidebarItemConfig} SidebarItemConfig + * @typedef {import('@docusaurus/plugin-content-docs').SidebarItemCategoryConfig} SidebarItemCategoryConfig */ /** @type {SidebarsConfig} */ From f580154a816171f515497f650038c112bdd53105 Mon Sep 17 00:00:00 2001 From: sebastien Date: Fri, 23 Oct 2026 18:14:48 +0200 Subject: [PATCH 2/8] refactor!: remove the lib/* and src/* wildcard exports of the docs, blog, live-codeblock and mermaid packages (AI-assisted) They were added for Jest 28, which the repository no longer uses. They made every file of these packages a public entry point. Co-Authored-By: Claude Opus 5.5 --- packages/docusaurus-plugin-content-blog/package.json | 2 -- packages/docusaurus-plugin-content-docs/package.json | 2 -- packages/docusaurus-theme-live-codeblock/package.json | 2 -- packages/docusaurus-theme-mermaid/package.json | 2 -- 4 files changed, 8 deletions(-) diff --git a/packages/docusaurus-plugin-content-blog/package.json b/packages/docusaurus-plugin-content-blog/package.json index f7a97f67ce1c..36d86af78955 100644 --- a/packages/docusaurus-plugin-content-blog/package.json +++ b/packages/docusaurus-plugin-content-blog/package.json @@ -5,8 +5,6 @@ "main": "lib/index.js", "types": "src/plugin-content-blog.d.ts", "exports": { - "./lib/*": "./lib/*", - "./src/*": "./src/*", "./client": { "type": "./lib/client/index.d.ts", "default": "./lib/client/index.js" diff --git a/packages/docusaurus-plugin-content-docs/package.json b/packages/docusaurus-plugin-content-docs/package.json index e5e3a78413dc..4d49341517e6 100644 --- a/packages/docusaurus-plugin-content-docs/package.json +++ b/packages/docusaurus-plugin-content-docs/package.json @@ -5,8 +5,6 @@ "main": "lib/index.js", "sideEffects": false, "exports": { - "./lib/*": "./lib/*", - "./src/*": "./src/*", "./client": { "type": "./lib/client/index.d.ts", "default": "./lib/client/index.js" diff --git a/packages/docusaurus-theme-live-codeblock/package.json b/packages/docusaurus-theme-live-codeblock/package.json index d101183db0fe..f2a3b27c2ccb 100644 --- a/packages/docusaurus-theme-live-codeblock/package.json +++ b/packages/docusaurus-theme-live-codeblock/package.json @@ -8,8 +8,6 @@ "lib/theme/Playground/*" ], "exports": { - "./lib/*": "./lib/*", - "./src/*": "./src/*", "./client": { "type": "./lib/client/index.d.ts", "default": "./lib/client/index.js" diff --git a/packages/docusaurus-theme-mermaid/package.json b/packages/docusaurus-theme-mermaid/package.json index 8d4ed9081a4f..fbbbd2716467 100644 --- a/packages/docusaurus-theme-mermaid/package.json +++ b/packages/docusaurus-theme-mermaid/package.json @@ -6,8 +6,6 @@ "types": "src/theme-mermaid.d.ts", "sideEffects": false, "exports": { - "./lib/*": "./lib/*", - "./src/*": "./src/*", "./client": { "type": "./lib/client/index.d.ts", "default": "./lib/client/index.js" From 439b5db6d968ca56047e85179bcd6149ca4a2765 Mon Sep 17 00:00:00 2001 From: sebastien Date: Wed, 21 Oct 2026 12:02:25 +0200 Subject: [PATCH 3/8] refactor(docs): remove unused CategoryMetadataFilenameBase constant (AI-assisted) Co-Authored-By: Claude Opus 5.5 --- .../docusaurus-plugin-content-docs/src/sidebars/generator.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/docusaurus-plugin-content-docs/src/sidebars/generator.ts b/packages/docusaurus-plugin-content-docs/src/sidebars/generator.ts index 7f1e3253fc78..3ab888317df4 100644 --- a/packages/docusaurus-plugin-content-docs/src/sidebars/generator.ts +++ b/packages/docusaurus-plugin-content-docs/src/sidebars/generator.ts @@ -26,7 +26,6 @@ function getLocalDocId(docId: string): string { return _.last(docId.split('/'))!; } -export const CategoryMetadataFilenameBase = '_category_'; export const CategoryMetadataFilenamePattern = '_category_.{json,yml,yaml}'; type WithPosition = T & { From c97f125757c950d17f57d6fc05d9527df59ac840 Mon Sep 17 00:00:00 2001 From: sebastien Date: Wed, 21 Oct 2026 12:02:16 +0200 Subject: [PATCH 4/8] refactor(blog): remove test-only validateAuthorsMap duplicate (AI-assisted) validateAuthorsMap() was an exact copy of validateAuthorsMapInput(), and only tests used it. Co-Authored-By: Claude Opus 5.5 --- .../src/__tests__/authorsMap.test.ts | 13 ++++++------- .../src/authorsMap.ts | 8 -------- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/packages/docusaurus-plugin-content-blog/src/__tests__/authorsMap.test.ts b/packages/docusaurus-plugin-content-blog/src/__tests__/authorsMap.test.ts index 9384bf6259a0..1522c5c3f55b 100644 --- a/packages/docusaurus-plugin-content-blog/src/__tests__/authorsMap.test.ts +++ b/packages/docusaurus-plugin-content-blog/src/__tests__/authorsMap.test.ts @@ -11,7 +11,6 @@ import { type AuthorsMapInput, checkAuthorsMapPermalinkCollisions, getAuthorsMap, - validateAuthorsMap, validateAuthorsMapInput, } from '../authorsMap'; import type {AuthorsMap} from '@docusaurus/plugin-content-blog'; @@ -305,7 +304,7 @@ describe('authors socials', () => { }, }; - expect(validateAuthorsMap(authorsMap)).toEqual(authorsMap); + expect(validateAuthorsMapInput(authorsMap)).toEqual(authorsMap); }); it('throw socials that are not strings', () => { @@ -338,17 +337,17 @@ describe('authors socials', () => { }; expect(() => - validateAuthorsMap(socialNumber), + validateAuthorsMapInput(socialNumber), ).toThrowErrorMatchingInlineSnapshot( `[ValidationError: "ozaki.socials.twitter" must be a string]`, ); expect(() => - validateAuthorsMap(socialNull), + validateAuthorsMapInput(socialNull), ).toThrowErrorMatchingInlineSnapshot( `[ValidationError: "ozaki.socials.twitter" must be a string]`, ); expect(() => - validateAuthorsMap(socialNull2), + validateAuthorsMapInput(socialNull2), ).toThrowErrorMatchingInlineSnapshot( `[ValidationError: "ozaki.socials" should be an author object containing properties like name, title, and imageURL.]`, ); @@ -366,7 +365,7 @@ describe('authors socials', () => { }; expect(() => - validateAuthorsMap(authorsMap), + validateAuthorsMapInput(authorsMap), ).toThrowErrorMatchingInlineSnapshot( `[ValidationError: "ozaki.socials.twitter" must be a string]`, ); @@ -384,6 +383,6 @@ describe('authors socials', () => { }, }; - expect(validateAuthorsMap(authorsMap)).toEqual(authorsMap); + expect(validateAuthorsMapInput(authorsMap)).toEqual(authorsMap); }); }); diff --git a/packages/docusaurus-plugin-content-blog/src/authorsMap.ts b/packages/docusaurus-plugin-content-blog/src/authorsMap.ts index e5c358b422f5..fd8f2eece562 100644 --- a/packages/docusaurus-plugin-content-blog/src/authorsMap.ts +++ b/packages/docusaurus-plugin-content-blog/src/authorsMap.ts @@ -168,11 +168,3 @@ export async function getAuthorsMap(params: { const authorsMap = normalizeAuthorsMap({authorsMapInput, ...params}); return authorsMap; } - -export function validateAuthorsMap(content: unknown): AuthorsMapInput { - const {error, value} = AuthorsMapInputSchema.validate(content); - if (error) { - throw error; - } - return value; -} From 9da8d0255bd8b0665dfcd6571d91e1544cecc4b2 Mon Sep 17 00:00:00 2001 From: sebastien Date: Fri, 23 Oct 2026 18:15:02 +0200 Subject: [PATCH 5/8] chore(knip): add the blog markdownLoader.ts webpack loader as a production entry (AI-assisted) Co-Authored-By: Claude Opus 5.5 --- knip.config.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/knip.config.ts b/knip.config.ts index 3af15e860e8a..8e2fa7311ff8 100644 --- a/knip.config.ts +++ b/knip.config.ts @@ -136,6 +136,8 @@ const config: KnipConfig = ({ ignoreDependencies: [/.*/], }, 'packages/docusaurus-plugin-content-blog': { + // Webpack loader, resolved with path.resolve(__dirname, ...) + entry: ['src/markdownLoader.ts!'], // Knip doesn't detect imports in "declare module" blocks ignoreDependencies: ['utility-types'], }, From 994cd12591d3e733bb5d15ef5c7c50cc2236f49f Mon Sep 17 00:00:00 2001 From: sebastien Date: Fri, 23 Oct 2026 18:15:37 +0200 Subject: [PATCH 6/8] refactor: remove the export keywords only used in their own file (AI-assisted) Knip reports them now that the lib/* and src/* wildcard exports don't make every file a public entry point. Co-Authored-By: Claude Opus 5.5 --- .../src/client/docsUtils.tsx | 2 +- packages/docusaurus-plugin-content-docs/src/routes.ts | 2 +- .../src/sidebars/index.ts | 2 +- .../src/sidebars/normalization.ts | 4 +--- .../src/sidebars/types.ts | 6 +++--- .../src/sidebars/utils.ts | 10 ++++------ .../src/versions/version.ts | 2 +- .../src/validateThemeConfig.ts | 2 +- .../src/validateThemeConfig.ts | 2 +- 9 files changed, 14 insertions(+), 18 deletions(-) diff --git a/packages/docusaurus-plugin-content-docs/src/client/docsUtils.tsx b/packages/docusaurus-plugin-content-docs/src/client/docsUtils.tsx index 474a58895ade..77453d820eca 100644 --- a/packages/docusaurus-plugin-content-docs/src/client/docsUtils.tsx +++ b/packages/docusaurus-plugin-content-docs/src/client/docsUtils.tsx @@ -76,7 +76,7 @@ export function findSidebarCategory( * Best effort to assign a link to a sidebar category. If the category doesn't * have a link itself, we link to the first sub item with a link. */ -export function findFirstSidebarItemCategoryLink( +function findFirstSidebarItemCategoryLink( item: PropSidebarItemCategory, ): string | undefined { if (item.href && !item.linkUnlisted) { diff --git a/packages/docusaurus-plugin-content-docs/src/routes.ts b/packages/docusaurus-plugin-content-docs/src/routes.ts index 50fd6d056ca2..b5660d9f784b 100644 --- a/packages/docusaurus-plugin-content-docs/src/routes.ts +++ b/packages/docusaurus-plugin-content-docs/src/routes.ts @@ -235,7 +235,7 @@ type BuildAllRoutesParam = Omit & { // TODO we want this buildAllRoutes function to be easily testable // Ideally, we should avoid side effects here (ie not injecting actions) -export async function buildAllRoutes( +async function buildAllRoutes( param: BuildAllRoutesParam, ): Promise { const subRoutes = await Promise.all( diff --git a/packages/docusaurus-plugin-content-docs/src/sidebars/index.ts b/packages/docusaurus-plugin-content-docs/src/sidebars/index.ts index 3dbf48414779..39d86c83c6d8 100644 --- a/packages/docusaurus-plugin-content-docs/src/sidebars/index.ts +++ b/packages/docusaurus-plugin-content-docs/src/sidebars/index.ts @@ -20,7 +20,7 @@ import {postProcessSidebars} from './postProcessor'; import type {PluginOptions} from '@docusaurus/plugin-content-docs'; import type {SidebarsConfig, Sidebars, SidebarProcessorParams} from './types'; -export const DefaultSidebars: SidebarsConfig = { +const DefaultSidebars: SidebarsConfig = { defaultSidebar: [ { type: 'autogenerated', diff --git a/packages/docusaurus-plugin-content-docs/src/sidebars/normalization.ts b/packages/docusaurus-plugin-content-docs/src/sidebars/normalization.ts index dad0f7c86c1c..0da8927cb4cc 100644 --- a/packages/docusaurus-plugin-content-docs/src/sidebars/normalization.ts +++ b/packages/docusaurus-plugin-content-docs/src/sidebars/normalization.ts @@ -34,9 +34,7 @@ function normalizeCategoriesShorthand( * Normalizes recursively item and all its children. Ensures that at the end * each item will be an object with the corresponding type. */ -export function normalizeItem( - item: SidebarItemConfig, -): NormalizedSidebarItem[] { +function normalizeItem(item: SidebarItemConfig): NormalizedSidebarItem[] { if (typeof item === 'string') { return [{type: 'doc', id: item}]; } diff --git a/packages/docusaurus-plugin-content-docs/src/sidebars/types.ts b/packages/docusaurus-plugin-content-docs/src/sidebars/types.ts index 550243b90ea3..f8b4f36a8f64 100644 --- a/packages/docusaurus-plugin-content-docs/src/sidebars/types.ts +++ b/packages/docusaurus-plugin-content-docs/src/sidebars/types.ts @@ -65,7 +65,7 @@ type SidebarItemCategoryBase = SidebarItemBase & { export type SidebarItemCategoryLinkDoc = {type: 'doc'; id: string}; -export type SidebarItemCategoryLinkGeneratedIndexConfig = { +type SidebarItemCategoryLinkGeneratedIndexConfig = { type: 'generated-index'; slug?: string; title?: string; @@ -160,7 +160,7 @@ export type SidebarItemCategory = Expand< } >; -export type SidebarItemCategoryWithLink = Required; +type SidebarItemCategoryWithLink = Required; export type SidebarItemCategoryWithGeneratedIndex = SidebarItemCategoryWithLink & {link: SidebarItemCategoryLinkGeneratedIndex}; @@ -250,7 +250,7 @@ export type SidebarItemsGeneratorVersion = Pick< 'versionName' | 'contentPath' >; -export type SidebarItemsGeneratorArgs = { +type SidebarItemsGeneratorArgs = { /** The sidebar item with type "autogenerated" to be transformed. */ item: SidebarItemAutogenerated; /** Useful metadata for the version this sidebar belongs to. */ diff --git a/packages/docusaurus-plugin-content-docs/src/sidebars/utils.ts b/packages/docusaurus-plugin-content-docs/src/sidebars/utils.ts index 3ed0e06099f8..3a45282aeea5 100644 --- a/packages/docusaurus-plugin-content-docs/src/sidebars/utils.ts +++ b/packages/docusaurus-plugin-content-docs/src/sidebars/utils.ts @@ -86,7 +86,7 @@ export function collectSidebarRefs(sidebar: Sidebar): SidebarItemDoc[] { } // /!\ docId order matters for navigation! -export function collectSidebarDocIds(sidebar: Sidebar): string[] { +function collectSidebarDocIds(sidebar: Sidebar): string[] { return flattenSidebarItems(sidebar).flatMap((item) => { if (item.type === 'category') { return item.link?.type === 'doc' ? [item.link.id] : []; @@ -98,9 +98,7 @@ export function collectSidebarDocIds(sidebar: Sidebar): string[] { }); } -export function collectSidebarNavigation( - sidebar: Sidebar, -): SidebarNavigationItem[] { +function collectSidebarNavigation(sidebar: Sidebar): SidebarNavigationItem[] { return flattenSidebarItems(sidebar).flatMap((item) => { if (item.type === 'category' && item.link) { return [item as SidebarNavigationItem]; @@ -118,13 +116,13 @@ export function collectSidebarsDocIds(sidebars: Sidebars): { return _.mapValues(sidebars, collectSidebarDocIds); } -export function collectSidebarsNavigations(sidebars: Sidebars): { +function collectSidebarsNavigations(sidebars: Sidebars): { [sidebarId: string]: SidebarNavigationItem[]; } { return _.mapValues(sidebars, collectSidebarNavigation); } -export type SidebarNavigation = { +type SidebarNavigation = { sidebarName: string | undefined; previous: SidebarNavigationItem | undefined; next: SidebarNavigationItem | undefined; diff --git a/packages/docusaurus-plugin-content-docs/src/versions/version.ts b/packages/docusaurus-plugin-content-docs/src/versions/version.ts index e06f50566ec9..4d5adcd3e2ad 100644 --- a/packages/docusaurus-plugin-content-docs/src/versions/version.ts +++ b/packages/docusaurus-plugin-content-docs/src/versions/version.ts @@ -141,7 +141,7 @@ export function getVersionBadge({ return options.versions[versionName]?.badge ?? defaultVersionBadge; } -export function getVersionNoIndex({ +function getVersionNoIndex({ versionName, options, }: VersionContext): VersionMetadata['noIndex'] { diff --git a/packages/docusaurus-theme-live-codeblock/src/validateThemeConfig.ts b/packages/docusaurus-theme-live-codeblock/src/validateThemeConfig.ts index d642214987de..264d607fe495 100644 --- a/packages/docusaurus-theme-live-codeblock/src/validateThemeConfig.ts +++ b/packages/docusaurus-theme-live-codeblock/src/validateThemeConfig.ts @@ -15,7 +15,7 @@ export const DEFAULT_CONFIG = { playgroundPosition: 'bottom', }; -export const Schema = Joi.object({ +const Schema = Joi.object({ liveCodeBlock: Joi.object({ playgroundPosition: Joi.string() .equal('top', 'bottom') diff --git a/packages/docusaurus-theme-mermaid/src/validateThemeConfig.ts b/packages/docusaurus-theme-mermaid/src/validateThemeConfig.ts index ceaf3b9ce7cf..5b2f93e6574a 100644 --- a/packages/docusaurus-theme-mermaid/src/validateThemeConfig.ts +++ b/packages/docusaurus-theme-mermaid/src/validateThemeConfig.ts @@ -19,7 +19,7 @@ export const DEFAULT_THEME_CONFIG: ThemeConfig = { }, }; -export const Schema = Joi.object({ +const Schema = Joi.object({ mermaid: Joi.object({ theme: Joi.object({ dark: Joi.string().default(DEFAULT_THEME_CONFIG.mermaid.theme.dark), From 887020aaf20d138b29f3b11137ba2ddee3402231 Mon Sep 17 00:00:00 2001 From: sebastien Date: Fri, 23 Oct 2026 18:16:01 +0200 Subject: [PATCH 7/8] chore(docs): tag the public Prop* sidebar types with @public for Knip (AI-assisted) plugin-content-docs.d.ts re-exports them with import() types in a "declare module" block, which Knip doesn't follow. Co-Authored-By: Claude Opus 5.5 --- .../src/sidebars/types.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/docusaurus-plugin-content-docs/src/sidebars/types.ts b/packages/docusaurus-plugin-content-docs/src/sidebars/types.ts index f8b4f36a8f64..39957f34ebce 100644 --- a/packages/docusaurus-plugin-content-docs/src/sidebars/types.ts +++ b/packages/docusaurus-plugin-content-docs/src/sidebars/types.ts @@ -182,7 +182,12 @@ export type Sidebars = { [sidebarId: string]: Sidebar; }; +// The Prop* types are public API: plugin-content-docs.d.ts re-exports them +// with import() types in a "declare module" block, which Knip doesn't follow. +// The @public tags prevent Knip from reporting them as unused exports. + // Doc links have been resolved to URLs, ready to be passed to the theme +/** @public */ export type PropSidebarItemCategory = Expand< SidebarItemCategoryBase & { items: PropSidebarItem[]; @@ -196,22 +201,28 @@ export type PropSidebarItemCategory = Expand< } >; +/** @public */ export type PropSidebarItemLink = SidebarItemLink & { docId?: string; unlisted?: boolean; }; +/** @public */ export type PropSidebarItemHtml = SidebarItemHtml; +/** @public */ export type PropSidebarItem = | PropSidebarItemLink | PropSidebarItemCategory | PropSidebarItemHtml; +/** @public */ export type PropSidebar = PropSidebarItem[]; +/** @public */ export type PropSidebars = { [sidebarId: string]: PropSidebar; }; +/** @public */ export type PropSidebarBreadcrumbsItem = | PropSidebarItemLink | PropSidebarItemCategory; From b1f4984b76f38ab0cd496d109cb16ebb7f2ca07c Mon Sep 17 00:00:00 2001 From: sebastien Date: Fri, 23 Oct 2026 18:19:35 +0200 Subject: [PATCH 8/8] Revert "refactor(blog): remove test-only validateAuthorsMap duplicate (AI-assisted)" This reverts commit c97f125757c950d17f57d6fc05d9527df59ac840. The validateAuthorsMap() removal has its own PR. (AI-assisted) Co-Authored-By: Claude Opus 5.5 --- .../src/__tests__/authorsMap.test.ts | 13 +++++++------ .../src/authorsMap.ts | 8 ++++++++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/packages/docusaurus-plugin-content-blog/src/__tests__/authorsMap.test.ts b/packages/docusaurus-plugin-content-blog/src/__tests__/authorsMap.test.ts index 1522c5c3f55b..9384bf6259a0 100644 --- a/packages/docusaurus-plugin-content-blog/src/__tests__/authorsMap.test.ts +++ b/packages/docusaurus-plugin-content-blog/src/__tests__/authorsMap.test.ts @@ -11,6 +11,7 @@ import { type AuthorsMapInput, checkAuthorsMapPermalinkCollisions, getAuthorsMap, + validateAuthorsMap, validateAuthorsMapInput, } from '../authorsMap'; import type {AuthorsMap} from '@docusaurus/plugin-content-blog'; @@ -304,7 +305,7 @@ describe('authors socials', () => { }, }; - expect(validateAuthorsMapInput(authorsMap)).toEqual(authorsMap); + expect(validateAuthorsMap(authorsMap)).toEqual(authorsMap); }); it('throw socials that are not strings', () => { @@ -337,17 +338,17 @@ describe('authors socials', () => { }; expect(() => - validateAuthorsMapInput(socialNumber), + validateAuthorsMap(socialNumber), ).toThrowErrorMatchingInlineSnapshot( `[ValidationError: "ozaki.socials.twitter" must be a string]`, ); expect(() => - validateAuthorsMapInput(socialNull), + validateAuthorsMap(socialNull), ).toThrowErrorMatchingInlineSnapshot( `[ValidationError: "ozaki.socials.twitter" must be a string]`, ); expect(() => - validateAuthorsMapInput(socialNull2), + validateAuthorsMap(socialNull2), ).toThrowErrorMatchingInlineSnapshot( `[ValidationError: "ozaki.socials" should be an author object containing properties like name, title, and imageURL.]`, ); @@ -365,7 +366,7 @@ describe('authors socials', () => { }; expect(() => - validateAuthorsMapInput(authorsMap), + validateAuthorsMap(authorsMap), ).toThrowErrorMatchingInlineSnapshot( `[ValidationError: "ozaki.socials.twitter" must be a string]`, ); @@ -383,6 +384,6 @@ describe('authors socials', () => { }, }; - expect(validateAuthorsMapInput(authorsMap)).toEqual(authorsMap); + expect(validateAuthorsMap(authorsMap)).toEqual(authorsMap); }); }); diff --git a/packages/docusaurus-plugin-content-blog/src/authorsMap.ts b/packages/docusaurus-plugin-content-blog/src/authorsMap.ts index fd8f2eece562..e5c358b422f5 100644 --- a/packages/docusaurus-plugin-content-blog/src/authorsMap.ts +++ b/packages/docusaurus-plugin-content-blog/src/authorsMap.ts @@ -168,3 +168,11 @@ export async function getAuthorsMap(params: { const authorsMap = normalizeAuthorsMap({authorsMapInput, ...params}); return authorsMap; } + +export function validateAuthorsMap(content: unknown): AuthorsMapInput { + const {error, value} = AuthorsMapInputSchema.validate(content); + if (error) { + throw error; + } + return value; +}