Browse Source

fix: toc inpage limit bug

fix/enable-imgix
Thomas Osmonson 4 years ago
committed by Thomas Osmonson
parent
commit
3165580301
  1. 2
      src/components/mdx/md-contents.tsx
  2. 3
      src/components/toc.tsx

2
src/components/mdx/md-contents.tsx

@ -266,7 +266,7 @@ export const MDContents: React.FC<any> = ({ pageTop: PageTop = null, headings, c
>
<Box position="sticky" top={0} pt={space('extra-loose')}>
{/*<Search mb={space('extra-loose')} />*/}
{headings?.length ? <TableOfContents limit={2} headings={headings} /> : null}
{headings?.length ? <TableOfContents limit headings={headings} /> : null}
</Box>
</Box>
) : null}

3
src/components/toc.tsx

@ -36,7 +36,8 @@ const Item = ({
const isActive = isOnScreen || _isActive;
const adjustedLevel = level - 2;
return adjustedLevel > 0 && adjustedLevel <= 2 ? (
const shouldRender = limit ? adjustedLevel > 0 && adjustedLevel <= 2 : true;
return shouldRender ? (
<Box pl={getLevelPadding(level - 2)} py={space('extra-tight')}>
<NextLink href={`#${slug}`} passHref>
<Link

Loading…
Cancel
Save