mirror of
https://github.com/Snigdha-OS/documentation.git
synced 2025-09-17 20:54:55 +02:00
54 lines
1.5 KiB
JavaScript
54 lines
1.5 KiB
JavaScript
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
import React, {useMemo} from 'react';
|
|
import {useThemeConfig} from '@docusaurus/theme-common';
|
|
import {
|
|
useTOCHighlight,
|
|
useFilteredAndTreeifiedTOC,
|
|
} from '@docusaurus/theme-common/internal';
|
|
import TOCItemTree from '@theme/TOCItems/Tree';
|
|
export default function TOCItems({
|
|
toc,
|
|
className = 'table-of-contents table-of-contents__left-border',
|
|
linkClassName = 'table-of-contents__link',
|
|
linkActiveClassName = undefined,
|
|
minHeadingLevel: minHeadingLevelOption,
|
|
maxHeadingLevel: maxHeadingLevelOption,
|
|
...props
|
|
}) {
|
|
const themeConfig = useThemeConfig();
|
|
const minHeadingLevel =
|
|
minHeadingLevelOption ?? themeConfig.tableOfContents.minHeadingLevel;
|
|
const maxHeadingLevel =
|
|
maxHeadingLevelOption ?? themeConfig.tableOfContents.maxHeadingLevel;
|
|
const tocTree = useFilteredAndTreeifiedTOC({
|
|
toc,
|
|
minHeadingLevel,
|
|
maxHeadingLevel,
|
|
});
|
|
const tocHighlightConfig = useMemo(() => {
|
|
if (linkClassName && linkActiveClassName) {
|
|
return {
|
|
linkClassName,
|
|
linkActiveClassName,
|
|
minHeadingLevel,
|
|
maxHeadingLevel,
|
|
};
|
|
}
|
|
return undefined;
|
|
}, [linkClassName, linkActiveClassName, minHeadingLevel, maxHeadingLevel]);
|
|
useTOCHighlight(tocHighlightConfig);
|
|
return (
|
|
<TOCItemTree
|
|
toc={tocTree}
|
|
className={className}
|
|
linkClassName={linkClassName}
|
|
{...props}
|
|
/>
|
|
);
|
|
}
|