blob: 869d0a5f0f2e5dc9f140f56195b72c64fb22805b [file] [log] [blame]
import React from 'react';
import clsx from 'clsx';
import TOCItems from '@theme/TOCItems';
import type { Props } from '@theme/TOC';
import styles from './styles.module.css';
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
import Link from '@docusaurus/Link';
import { ExternalLinkArrowIcon } from '../../components/Icons/external-link-arrow-icon';
// Using a custom className
// This prevents TOCInline/TOCCollapsible getting highlighted by mistake
const LINK_CLASS_NAME = 'table-of-contents__link toc-highlight';
const LINK_ACTIVE_CLASS_NAME = 'table-of-contents__link--active';
export default function TOC({ className, ...props }: Props): JSX.Element {
const { siteConfig } = useDocusaurusContext();
const isCN = siteConfig.baseUrl.indexOf('zh-CN') > -1;
return (
<div className={clsx(styles.tableOfContents, 'thin-scrollbar', className)}>
<span className="ml-4">{!isCN ? 'On This Page' : '本页导航'}</span>
<TOCItems {...props} linkClassName={LINK_CLASS_NAME} linkActiveClassName={LINK_ACTIVE_CLASS_NAME} />
</div>
);
}