Skip to content

Commit

Permalink
feat: support hiding toc
Browse files Browse the repository at this point in the history
  • Loading branch information
yndx-birman committed Jul 15, 2021
1 parent 033a824 commit b3446a1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/components/DocLayout/DocLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface DocLayoutProps {
headerHeight?: number;
tocTitleIcon?: React.ReactNode;
hideTocHeader?: boolean;
hideToc?: boolean;
className?: string;
loading?: boolean;
}
Expand Down Expand Up @@ -90,9 +91,9 @@ export class DocLayout extends React.Component<DocLayoutProps> {
}

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;
}

Expand Down
4 changes: 3 additions & 1 deletion src/components/DocLeadingPage/DocLeadingPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface DocLeadingPageProps extends DocLeadingPageData {
headerHeight?: number;
wideFormat?: boolean;
hideTocHeader?: boolean;
hideToc?: boolean;
tocTitleIcon?: React.ReactNode;
}

Expand Down Expand Up @@ -91,7 +92,7 @@ export const Links: React.FC<DocLinksProps> = ({links, isRoot}) => {

export const DocLeadingPage: React.FC<DocLeadingPageProps> = ({
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,
Expand All @@ -105,6 +106,7 @@ export const DocLeadingPage: React.FC<DocLeadingPageProps> = ({
headerHeight={headerHeight}
className={b(modes)}
hideTocHeader={hideTocHeader}
hideToc={hideToc}
tocTitleIcon={tocTitleIcon}
>
<span/>
Expand Down
3 changes: 3 additions & 0 deletions src/components/DocPage/DocPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export interface DocPageProps extends DocPageData, Partial<DocSettings> {
headerHeight?: number;
tocTitleIcon?: React.ReactNode;
hideTocHeader?: boolean;
hideToc?: boolean;

renderLoader?: () => React.ReactNode;
convertPathToOriginalArticle?: (path: string) => string;
Expand Down Expand Up @@ -91,6 +92,7 @@ class DocPage extends React.Component<DocPageInnerProps, DocPageState> {
singlePage,
tocTitleIcon,
hideTocHeader,
hideToc,
} = this.props;

const asideMiniToc = this.renderAsideMiniToc();
Expand All @@ -114,6 +116,7 @@ class DocPage extends React.Component<DocPageInnerProps, DocPageState> {
tocTitleIcon={tocTitleIcon}
wideFormat={wideFormat}
hideTocHeader={hideTocHeader}
hideToc={hideToc}
loading={this.state.loading}
>
<DocLayout.Center>
Expand Down

0 comments on commit b3446a1

Please sign in to comment.