feat(docs,theme-classic): docs breadcrumbs (#6517)

Co-authored-by: sebastienlorber <lorber.sebastien@gmail.com>
This commit is contained in:
Jody Heavener 2022-02-16 14:02:58 -04:00 committed by GitHub
parent 67918e35e2
commit 3629b5ab39
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 341 additions and 1 deletions

View file

@ -242,6 +242,7 @@ exports[`simple website content 5`] = `
Object {
"pluginName": Object {
"pluginId": Object {
"breadcrumbs": true,
"path": "/docs",
"versions": Array [
Object {
@ -955,6 +956,7 @@ exports[`simple website content: global data 1`] = `
Object {
"pluginName": Object {
"pluginId": Object {
"breadcrumbs": true,
"path": "/docs",
"versions": Array [
Object {
@ -2411,6 +2413,7 @@ exports[`versioned website (community) content: global data 1`] = `
Object {
"pluginName": Object {
"pluginId": Object {
"breadcrumbs": true,
"path": "/community",
"versions": Array [
Object {
@ -3450,6 +3453,7 @@ exports[`versioned website content: global data 1`] = `
Object {
"pluginName": Object {
"pluginId": Object {
"breadcrumbs": true,
"path": "/docs",
"versions": Array [
Object {

View file

@ -56,6 +56,7 @@ describe('normalizeDocsPluginOptions', () => {
rehypePlugins: [markdownPluginsFunctionStub],
beforeDefaultRehypePlugins: [],
beforeDefaultRemarkPlugins: [],
breadcrumbs: true,
showLastUpdateTime: true,
showLastUpdateAuthor: true,
admonitions: {},

View file

@ -217,6 +217,7 @@ export default async function pluginContentDocs(
docLayoutComponent,
docItemComponent,
docCategoryGeneratedIndexComponent,
breadcrumbs,
} = options;
const {addRoute, createData, setGlobalData} = actions;
@ -295,6 +296,7 @@ export default async function pluginContentDocs(
setGlobalData<GlobalPluginData>({
path: normalizeUrl([baseUrl, options.routeBasePath]),
versions: loadedVersions.map(toGlobalDataVersion),
breadcrumbs,
});
},

View file

@ -55,6 +55,7 @@ export const DEFAULT_OPTIONS: Omit<PluginOptions, 'id' | 'sidebarPath'> = {
editLocalizedFiles: false,
sidebarCollapsible: true,
sidebarCollapsed: true,
breadcrumbs: true,
};
const VersionOptionsSchema = Joi.object({
@ -139,6 +140,7 @@ export const OptionsSchema = Joi.object({
disableVersioning: Joi.bool().default(DEFAULT_OPTIONS.disableVersioning),
lastVersion: Joi.string().optional(),
versions: VersionsOptionsSchema,
breadcrumbs: Joi.bool().default(DEFAULT_OPTIONS.breadcrumbs),
});
export function validateOptions({

View file

@ -38,6 +38,7 @@ declare module '@docusaurus/plugin-content-docs' {
showLastUpdateTime?: boolean;
showLastUpdateAuthor?: boolean;
numberPrefixParser: NumberPrefixParser;
breadcrumbs: boolean;
};
export type PathOptions = {
@ -126,6 +127,8 @@ declare module '@docusaurus/plugin-content-docs' {
export type PropSidebarItemCategory =
import('./sidebars/types').PropSidebarItemCategory;
export type PropSidebarItem = import('./sidebars/types').PropSidebarItem;
export type PropSidebarBreadcrumbsItem =
import('./sidebars/types').PropSidebarBreadcrumbsItem;
export type PropSidebar = import('./sidebars/types').PropSidebar;
export type PropSidebars = import('./sidebars/types').PropSidebars;
@ -237,6 +240,10 @@ declare module '@theme/DocTagDocListPage' {
export default function DocTagDocListPage(props: Props): JSX.Element;
}
declare module '@theme/DocBreadcrumbs' {
export default function DocBreadcrumbs(): JSX.Element;
}
declare module '@theme/DocPage' {
import type {PropVersionMetadata} from '@docusaurus/plugin-content-docs';
import type {DocumentRoute} from '@theme/DocItem';
@ -294,6 +301,7 @@ declare module '@docusaurus/plugin-content-docs/client' {
export type GlobalPluginData = {
path: string;
versions: GlobalVersion[];
breadcrumbs: boolean;
};
export type DocVersionSuggestions = {
// suggest the latest version

View file

@ -195,6 +195,10 @@ export type PropSidebars = {
[sidebarId: string]: PropSidebar;
};
export type PropSidebarBreadcrumbsItem =
| PropSidebarItemLink
| PropSidebarItemCategory;
export type PropVersionDoc = {
id: string;
title: string;