diff --git a/packages/docusaurus-plugin-content-docs/src/__tests__/__snapshots__/index.test.ts.snap b/packages/docusaurus-plugin-content-docs/src/__tests__/__snapshots__/index.test.ts.snap index 88fb0433601c..3fb1a48e0a71 100644 --- a/packages/docusaurus-plugin-content-docs/src/__tests__/__snapshots__/index.test.ts.snap +++ b/packages/docusaurus-plugin-content-docs/src/__tests__/__snapshots__/index.test.ts.snap @@ -242,7 +242,7 @@ exports[`simple website content 5`] = ` Object { "pluginName": Object { "pluginId": Object { - "breadcrumbs": "nested", + "breadcrumbs": true, "path": "/docs", "versions": Array [ Object { @@ -956,7 +956,7 @@ exports[`simple website content: global data 1`] = ` Object { "pluginName": Object { "pluginId": Object { - "breadcrumbs": "nested", + "breadcrumbs": true, "path": "/docs", "versions": Array [ Object { @@ -2413,7 +2413,7 @@ exports[`versioned website (community) content: global data 1`] = ` Object { "pluginName": Object { "pluginId": Object { - "breadcrumbs": "nested", + "breadcrumbs": true, "path": "/community", "versions": Array [ Object { @@ -3453,7 +3453,7 @@ exports[`versioned website content: global data 1`] = ` Object { "pluginName": Object { "pluginId": Object { - "breadcrumbs": "nested", + "breadcrumbs": true, "path": "/docs", "versions": Array [ Object { diff --git a/packages/docusaurus-plugin-content-docs/src/__tests__/options.test.ts b/packages/docusaurus-plugin-content-docs/src/__tests__/options.test.ts index 5ef88f9e26ba..95fb65e38c9f 100644 --- a/packages/docusaurus-plugin-content-docs/src/__tests__/options.test.ts +++ b/packages/docusaurus-plugin-content-docs/src/__tests__/options.test.ts @@ -56,7 +56,7 @@ describe('normalizeDocsPluginOptions', () => { rehypePlugins: [markdownPluginsFunctionStub], beforeDefaultRehypePlugins: [], beforeDefaultRemarkPlugins: [], - breadcrumbs: 'nested', + breadcrumbs: true, showLastUpdateTime: true, showLastUpdateAuthor: true, admonitions: {}, diff --git a/packages/docusaurus-plugin-content-docs/src/options.ts b/packages/docusaurus-plugin-content-docs/src/options.ts index 520652578c2b..3e5e9f5a7a97 100644 --- a/packages/docusaurus-plugin-content-docs/src/options.ts +++ b/packages/docusaurus-plugin-content-docs/src/options.ts @@ -55,7 +55,7 @@ export const DEFAULT_OPTIONS: Omit = { editLocalizedFiles: false, sidebarCollapsible: true, sidebarCollapsed: true, - breadcrumbs: 'nested', + breadcrumbs: true, }; const VersionOptionsSchema = Joi.object({ @@ -140,10 +140,7 @@ export const OptionsSchema = Joi.object({ disableVersioning: Joi.bool().default(DEFAULT_OPTIONS.disableVersioning), lastVersion: Joi.string().optional(), versions: VersionsOptionsSchema, - breadcrumbs: Joi.alternatives( - Joi.bool(), - Joi.string().valid('nested'), - ).default(DEFAULT_OPTIONS.breadcrumbs), + breadcrumbs: Joi.bool().default(DEFAULT_OPTIONS.breadcrumbs), }); export function validateOptions({ 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 d205affe712c..00c4e8fda250 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 @@ -38,7 +38,7 @@ declare module '@docusaurus/plugin-content-docs' { showLastUpdateTime?: boolean; showLastUpdateAuthor?: boolean; numberPrefixParser: NumberPrefixParser; - breadcrumbs: boolean | 'nested'; + breadcrumbs: boolean; }; export type PathOptions = { @@ -301,7 +301,7 @@ declare module '@docusaurus/plugin-content-docs/client' { export type GlobalPluginData = { path: string; versions: GlobalVersion[]; - breadcrumbs: boolean | 'nested'; + breadcrumbs: boolean; }; export type DocVersionSuggestions = { // suggest the latest version diff --git a/packages/docusaurus-theme-common/src/utils/docsUtils.tsx b/packages/docusaurus-theme-common/src/utils/docsUtils.tsx index dcf8f0d9fe4a..f02b213c32dd 100644 --- a/packages/docusaurus-theme-common/src/utils/docsUtils.tsx +++ b/packages/docusaurus-theme-common/src/utils/docsUtils.tsx @@ -220,17 +220,11 @@ export function getBreadcrumbs({ export function useSidebarBreadcrumbs(): PropSidebarBreadcrumbsItem[] | null { const sidebar = useDocsSidebar(); const {pathname} = useLocation(); - const breadcrumbsOption = useActivePlugin()?.pluginData?.breadcrumbs; + const breadcrumbsOption = useActivePlugin()?.pluginData.breadcrumbs; - if (!sidebar || breadcrumbsOption === false) { + if (breadcrumbsOption === false || !sidebar) { return null; } - const breadcrumbs = getBreadcrumbs({sidebar, pathname}); - - if (breadcrumbsOption === 'nested' && breadcrumbs.length < 2) { - return null; - } - - return breadcrumbs; + return getBreadcrumbs({sidebar, pathname}); }