Skip to content

Commit

Permalink
remove nested option
Browse files Browse the repository at this point in the history
  • Loading branch information
slorber committed Feb 16, 2022
1 parent 8a76974 commit 6ca6697
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ exports[`simple website content 5`] = `
Object {
"pluginName": Object {
"pluginId": Object {
"breadcrumbs": "nested",
"breadcrumbs": true,
"path": "/docs",
"versions": Array [
Object {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe('normalizeDocsPluginOptions', () => {
rehypePlugins: [markdownPluginsFunctionStub],
beforeDefaultRehypePlugins: [],
beforeDefaultRemarkPlugins: [],
breadcrumbs: 'nested',
breadcrumbs: true,
showLastUpdateTime: true,
showLastUpdateAuthor: true,
admonitions: {},
Expand Down
7 changes: 2 additions & 5 deletions packages/docusaurus-plugin-content-docs/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const DEFAULT_OPTIONS: Omit<PluginOptions, 'id' | 'sidebarPath'> = {
editLocalizedFiles: false,
sidebarCollapsible: true,
sidebarCollapsed: true,
breadcrumbs: 'nested',
breadcrumbs: true,
};

const VersionOptionsSchema = Joi.object({
Expand Down Expand Up @@ -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({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ declare module '@docusaurus/plugin-content-docs' {
showLastUpdateTime?: boolean;
showLastUpdateAuthor?: boolean;
numberPrefixParser: NumberPrefixParser;
breadcrumbs: boolean | 'nested';
breadcrumbs: boolean;
};

export type PathOptions = {
Expand Down Expand Up @@ -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
Expand Down
12 changes: 3 additions & 9 deletions packages/docusaurus-theme-common/src/utils/docsUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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});
}

0 comments on commit 6ca6697

Please sign in to comment.