export default function NavbarContent()

in src/theme/Navbar/Content/index.tsx [69:129]


export default function NavbarContent(): ReactNode {
    const location = useLocation();
    const [currentNavbar, setCurrentNavbar] = useState(getCurrentNavBar(location.pathname));
    const [isEN, setIsEN] = useState(!location.pathname.includes('zh-CN'));

    const mobileSidebar = useNavbarMobileSidebar();
    const { showSearchPageMobile } = useContext(DataContext);

    const NavbarTypes = {
        [NavBar.DOCS]: {
            left: <NavbarDocsLeft isEN={isEN} />,
            right: <NavbarDocsRight isEN={isEN} />,
            bottom: <NavbarDocsBottom isEN={isEN} />,
        },
        [NavBar.COMMUNITY]: {
            left: <NavbarCommunityLeft />,
            right: <NavbarCommunityRight />,
            bottom: <NavbarCommunityBottom />,
        },
        [NavBar.COMMON]: {
            left: <NavbarCommonLeft />,
            right: <NavbarCommonRight star={STAR_COUNT} />,
            bottom: null,
        },
    };

    useEffect(() => {
        if (typeof window !== 'undefined') {
            const pathname = location.pathname.split('/')[1];
            location.pathname.includes('zh-CN') ? setIsEN(false) : setIsEN(true);
            if (location.pathname.includes(NavBar.DOCS) || location.pathname.includes(ARCHIVE_PATH)) {
                setCurrentNavbar(NavBar.DOCS);
            } else if (pathname === NavBar.COMMUNITY || location.pathname.includes('zh-CN/community')) {
                setCurrentNavbar(NavBar.COMMUNITY);
            } else {
                setCurrentNavbar(NavBar.COMMON);
            }
        }
    }, [typeof window !== 'undefined' && location.pathname]);

    return (
        <NavbarContentLayout
            left={NavbarTypes[currentNavbar].left}
            right={
                <>
                    {NavbarTypes[currentNavbar].right}
                    {!mobileSidebar.disabled && !showSearchPageMobile && <NavbarMobileSidebarToggle />}
                    <NavbarColorModeToggle className={styles.colorModeToggle} />
                    <Link className="header-right-button-primary navbar-download-desktop" to="/download">
                        <Translate id="navbar.download">
                            {typeof window !== 'undefined' && location.pathname.includes('zh-CN/docs')
                                ? '下载'
                                : 'Download'}
                        </Translate>
                    </Link>
                </>
            }
            bottom={!showSearchPageMobile ? NavbarTypes[currentNavbar].bottom : null}
        />
    );
}