diff --git a/website/src/theme/DocSidebarItem/index.js b/website/src/theme/DocSidebarItem/index.js
index d90714f1..deeef661 100644
--- a/website/src/theme/DocSidebarItem/index.js
+++ b/website/src/theme/DocSidebarItem/index.js
@@ -11,7 +11,9 @@ import {
usePrevious,
Collapsible,
useCollapsible,
+ ThemeClassNames,
} from '@docusaurus/theme-common';
+import Link from '@docusaurus/Link';
import isInternalUrl from '@docusaurus/isInternalUrl';
import IconExternalLink from '@theme/IconExternalLink';
import styles from './styles.module.css';
@@ -74,8 +76,14 @@ function useAutoExpandActiveCategory({isActive, collapsed, setCollapsed}) {
}, [isActive, wasActive, collapsed]);
}
-function DocSidebarItemCategory({item, onItemClick, activePath, ...props}) {
- const {items, label, collapsible} = item;
+function DocSidebarItemCategory({
+ item,
+ onItemClick,
+ activePath,
+ level,
+ ...props
+}) {
+ const {items, label, collapsible, className} = item;
const isActive = isActiveSidebarItem(item, activePath);
const {collapsed, setCollapsed, toggleCollapsed} = useCollapsible({
// active categories are always initialized as expanded
@@ -95,9 +103,15 @@ function DocSidebarItemCategory({item, onItemClick, activePath, ...props}) {
});
return (
+ className={clsx(
+ ThemeClassNames.docs.docSidebarItemCategory,
+ ThemeClassNames.docs.docSidebarItemCategoryLevel(level),
+ 'menu__list-item',
+ {
+ 'menu__list-item--collapsed': collapsed,
+ },
+ className,
+ )}>
{/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
);
}
-function DocSidebarItemLink({item, onItemClick, activePath, ...props}) {
- const {href, label} = item;
+function DocSidebarItemLink({item, onItemClick, activePath, level, ...props}) {
+ const {href, label, className} = item;
const isActive = isActiveSidebarItem(item, activePath);
return (
-
+
{isInternalUrl(href) ? (
label
diff --git a/website/src/theme/TOC/index.js b/website/src/theme/TOC/index.js
index da6fc58e..801e6ac0 100644
--- a/website/src/theme/TOC/index.js
+++ b/website/src/theme/TOC/index.js
@@ -6,50 +6,25 @@
*/
import React from 'react';
import clsx from 'clsx';
-import useTOCHighlight from '@theme/hooks/useTOCHighlight';
-import styles from './styles.module.css';
+import TOCItems from '@theme/TOCItems';
+import styles from './styles.module.css'; // Using a custom className
import SidebarAd from '../../components/SidebarAd';
+// This prevents TOC highlighting to highlight TOCInline/TOCCollapsible by mistake
-const LINK_CLASS_NAME = 'table-of-contents__link';
-const ACTIVE_LINK_CLASS_NAME = 'table-of-contents__link--active';
-const TOP_OFFSET = 100;
-/* eslint-disable jsx-a11y/control-has-associated-label */
-
-export function TOCHeadings({toc, isChild}) {
- if (!toc.length) {
- return null;
- }
+const LINK_CLASS_NAME = 'table-of-contents__link toc-highlight';
+const LINK_ACTIVE_CLASS_NAME = 'table-of-contents__link--active';
+function TOC({className, ...props}) {
return (
-
- {toc.map((heading) => (
- -
-
-
-
- ))}
-
- );
-}
-
-function TOC({toc}) {
- useTOCHighlight(LINK_CLASS_NAME, ACTIVE_LINK_CLASS_NAME, TOP_OFFSET);
- return (
-
+
);
}
diff --git a/website/src/theme/TOC/styles.module.css b/website/src/theme/TOC/styles.module.css
index 9e519333..4b6d2bcc 100644
--- a/website/src/theme/TOC/styles.module.css
+++ b/website/src/theme/TOC/styles.module.css
@@ -12,7 +12,7 @@
top: calc(var(--ifm-navbar-height) + 1rem);
}
-@media only screen and (max-width: 996px) {
+@media (max-width: 996px) {
.tableOfContents {
display: none;
}