mirror of
https://github.com/facebook/docusaurus.git
synced 2025-12-26 01:33:02 +00:00
Merge 1735903a56 into 5bc5c90dc7
This commit is contained in:
commit
2321d7ae41
|
|
@ -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, PluginOptions>,
|
||||
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();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -68,13 +68,14 @@ export async function readVersionDocs(
|
|||
): Promise<DocFile[]> {
|
||||
const sources = await Globby(options.include, {
|
||||
cwd: versionMetadata.contentPath,
|
||||
ignore: options.exclude,
|
||||
// // 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({
|
||||
|
|
|
|||
Loading…
Reference in New Issue