Skip to content

Commit

Permalink
hide mobile collapsible doc toc if no headings
Browse files Browse the repository at this point in the history
  • Loading branch information
slorber committed Jul 15, 2021
1 parent 818fb39 commit b634af1
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions packages/docusaurus-theme-classic/src/theme/DocItem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,14 @@ function DocItem(props: Props): JSX.Element {

const windowSize = useWindowSize();

const canRenderTOC =
!hideTableOfContents && DocContent.toc && DocContent.toc.length > 0;

const renderTocMobile =
!hideTableOfContents &&
DocContent.toc &&
(windowSize === 'mobile' || windowSize === 'ssr');
canRenderTOC && (windowSize === 'mobile' || windowSize === 'ssr');

const renderTocDesktop =
!hideTableOfContents &&
DocContent.toc &&
(windowSize === 'desktop' || windowSize === 'ssr');
canRenderTOC && (windowSize === 'desktop' || windowSize === 'ssr');

return (
<>
Expand Down

0 comments on commit b634af1

Please sign in to comment.