diff --git a/packages/plugin-docs/client/theme-doc/Layout.tsx b/packages/plugin-docs/client/theme-doc/Layout.tsx index 576890e0808a..e3e96071d74a 100644 --- a/packages/plugin-docs/client/theme-doc/Layout.tsx +++ b/packages/plugin-docs/client/theme-doc/Layout.tsx @@ -1,6 +1,8 @@ import cx from 'classnames'; import React, { Fragment, useEffect, useState } from 'react'; import { Helmet } from 'react-helmet'; +// @ts-ignore +import { useLocation } from 'umi'; import Announcement from './components/Announcement'; import { ThemeContext } from './context'; import Head from './Head'; @@ -31,10 +33,12 @@ export default (props: any) => { }, []); const { title, description } = props.themeConfig; - + const location = useLocation?.(); const isHomePage = window.location.pathname === '/' || - window.location.pathname.replace(/[a-z]{2}-[A-Z]{2}\/?/, '') === '/'; + window.location.pathname.replace(/[a-z]{2}-[A-Z]{2}\/?/, '') === '/' || + location?.pathname === '/' || + location?.pathname.replace(/[a-z]{2}-[A-Z]{2}\/?/, '') === '/'; return (