From 23972dd061ee973d7f4a66da61903f9d2ed2d4cc Mon Sep 17 00:00:00 2001 From: Kaparthy Reddy Date: Thu, 25 Dec 2025 11:54:16 +0530 Subject: [PATCH 1/2] fix(docs): ensure exclude patterns are recursive for nested directories --- .../src/__tests__/index.test.ts | 32 +++++++++++++++++++ .../src/docs.ts | 3 +- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/packages/docusaurus-plugin-content-docs/src/__tests__/index.test.ts b/packages/docusaurus-plugin-content-docs/src/__tests__/index.test.ts index 26594bc95d..edffdf4e4a 100644 --- a/packages/docusaurus-plugin-content-docs/src/__tests__/index.test.ts +++ b/packages/docusaurus-plugin-content-docs/src/__tests__/index.test.ts @@ -976,3 +976,35 @@ describe('site with custom sidebar items generator', () => { expect(version.sidebars).toMatchSnapshot(); }); }); +describe('nested directory exclusion (issue #11607)', () => { + it('excludes nested directories and their contents correctly', async () => { + const siteDir = path.join( + __dirname, + '__fixtures__/site-with-autogenerated-sidebar', + ); + + const context = await loadContext({siteDir}); + + const options = validateOptions({ + validate: normalizePluginOptions as Validate, + options: { + path: 'docs', + // We use the actual folder name '3-API' found in the fixture + exclude: ['3-API'], + }, + }); + + const plugin = await pluginContentDocs(context, options); + const content = await plugin.loadContent!(); + const currentVersion = content.loadedVersions[0]!; + + // This ensures we actually loaded the other docs (Getting Started, etc.) + expect(currentVersion.docs.length).toBeGreaterThan(0); + + // If the bug exists, this will find "API/api-overview" + // and the test will FAIL (because we expect it to be undefined) + const apiDoc = currentVersion.docs.find((doc) => doc.id.includes('API')); + + expect(apiDoc).toBeUndefined(); + }); +}); diff --git a/packages/docusaurus-plugin-content-docs/src/docs.ts b/packages/docusaurus-plugin-content-docs/src/docs.ts index b8f02ba5b0..0cfd2a93b7 100644 --- a/packages/docusaurus-plugin-content-docs/src/docs.ts +++ b/packages/docusaurus-plugin-content-docs/src/docs.ts @@ -68,7 +68,8 @@ export async function readVersionDocs( ): Promise { const sources = await Globby(options.include, { cwd: versionMetadata.contentPath, - ignore: options.exclude, + // THE FIX: Transform simple folder names into recursive glob patterns + ignore: options.exclude.flatMap((pattern) => [pattern, `${pattern}/**`]), }); return Promise.all( sources.map((source) => readDocFile(versionMetadata, source)), From 1735903a569ebaaa5a3678c2ccf4fa14f57b6a94 Mon Sep 17 00:00:00 2001 From: Kaparthy Reddy Date: Thu, 25 Dec 2025 12:08:01 +0530 Subject: [PATCH 2/2] docs: add magic comment anchors for documentation linking (#11617) --- packages/docusaurus-plugin-content-docs/src/docs.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/docusaurus-plugin-content-docs/src/docs.ts b/packages/docusaurus-plugin-content-docs/src/docs.ts index 0cfd2a93b7..b5bdd9599c 100644 --- a/packages/docusaurus-plugin-content-docs/src/docs.ts +++ b/packages/docusaurus-plugin-content-docs/src/docs.ts @@ -68,14 +68,14 @@ export async function readVersionDocs( ): Promise { const sources = await Globby(options.include, { cwd: versionMetadata.contentPath, - // THE FIX: Transform simple folder names into recursive glob patterns + // // anchor-next-line fix-11607-11617 + // Fix #11607: ensure folder exclusion is recursive by adding the /** glob ignore: options.exclude.flatMap((pattern) => [pattern, `${pattern}/**`]), }); return Promise.all( sources.map((source) => readDocFile(versionMetadata, source)), ); } - export type DocEnv = 'production' | 'development'; async function doProcessDocMetadata({