From b3446a11ebaac0f33872f7a54568b795b7ece8c6 Mon Sep 17 00:00:00 2001 From: birman111 Date: Thu, 15 Jul 2021 04:02:35 +0300 Subject: [PATCH] feat: support hiding toc --- src/components/DocLayout/DocLayout.tsx | 5 +++-- src/components/DocLeadingPage/DocLeadingPage.tsx | 4 +++- src/components/DocPage/DocPage.tsx | 3 +++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/components/DocLayout/DocLayout.tsx b/src/components/DocLayout/DocLayout.tsx index 189d8431..92578f33 100644 --- a/src/components/DocLayout/DocLayout.tsx +++ b/src/components/DocLayout/DocLayout.tsx @@ -24,6 +24,7 @@ export interface DocLayoutProps { headerHeight?: number; tocTitleIcon?: React.ReactNode; hideTocHeader?: boolean; + hideToc?: boolean; className?: string; loading?: boolean; } @@ -90,9 +91,9 @@ export class DocLayout extends React.Component { } private renderToc() { - const {toc, router, headerHeight, tocTitleIcon, hideRight, wideFormat, hideTocHeader} = this.props; + const {toc, router, headerHeight, tocTitleIcon, hideRight, wideFormat, hideTocHeader, hideToc} = this.props; - if (!toc) { + if (!toc || hideToc) { return null; } diff --git a/src/components/DocLeadingPage/DocLeadingPage.tsx b/src/components/DocLeadingPage/DocLeadingPage.tsx index b3e206e9..86d0169e 100644 --- a/src/components/DocLeadingPage/DocLeadingPage.tsx +++ b/src/components/DocLeadingPage/DocLeadingPage.tsx @@ -21,6 +21,7 @@ export interface DocLeadingPageProps extends DocLeadingPageData { headerHeight?: number; wideFormat?: boolean; hideTocHeader?: boolean; + hideToc?: boolean; tocTitleIcon?: React.ReactNode; } @@ -91,7 +92,7 @@ export const Links: React.FC = ({links, isRoot}) => { export const DocLeadingPage: React.FC = ({ data: {title, description, links}, - toc, router, lang, headerHeight, wideFormat = defaultWideFormat, hideTocHeader, tocTitleIcon, + toc, router, lang, headerHeight, wideFormat = defaultWideFormat, hideTocHeader, hideToc, tocTitleIcon, }) => { const modes = { 'regular-page-width': !wideFormat, @@ -105,6 +106,7 @@ export const DocLeadingPage: React.FC = ({ headerHeight={headerHeight} className={b(modes)} hideTocHeader={hideTocHeader} + hideToc={hideToc} tocTitleIcon={tocTitleIcon} > diff --git a/src/components/DocPage/DocPage.tsx b/src/components/DocPage/DocPage.tsx index 78cfd6d2..2de03b0f 100644 --- a/src/components/DocPage/DocPage.tsx +++ b/src/components/DocPage/DocPage.tsx @@ -31,6 +31,7 @@ export interface DocPageProps extends DocPageData, Partial { headerHeight?: number; tocTitleIcon?: React.ReactNode; hideTocHeader?: boolean; + hideToc?: boolean; renderLoader?: () => React.ReactNode; convertPathToOriginalArticle?: (path: string) => string; @@ -91,6 +92,7 @@ class DocPage extends React.Component { singlePage, tocTitleIcon, hideTocHeader, + hideToc, } = this.props; const asideMiniToc = this.renderAsideMiniToc(); @@ -114,6 +116,7 @@ class DocPage extends React.Component { tocTitleIcon={tocTitleIcon} wideFormat={wideFormat} hideTocHeader={hideTocHeader} + hideToc={hideToc} loading={this.state.loading} >