From 880a57298ebc015e29f44f9483bd4c58cfe541e1 Mon Sep 17 00:00:00 2001 From: Wuxh Date: Thu, 1 Dec 2022 10:43:52 +0800 Subject: [PATCH] chore(site): support for opening debug component demos (#39132) --- .dumi/theme/slots/Content/index.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.dumi/theme/slots/Content/index.tsx b/.dumi/theme/slots/Content/index.tsx index f65e1e9254..a0688f2db7 100644 --- a/.dumi/theme/slots/Content/index.tsx +++ b/.dumi/theme/slots/Content/index.tsx @@ -101,7 +101,7 @@ type AnchorItem = { const Content: React.FC<{ children: ReactNode }> = ({ children }) => { const meta = useRouteMeta(); - const { pathname } = useLocation(); + const { pathname, hash } = useLocation(); const { formatMessage } = useIntl(); const styles = useStyle(); const { direction } = useContext(SiteContext); @@ -112,8 +112,10 @@ const Content: React.FC<{ children: ReactNode }> = ({ children }) => { [meta], ); + const isDebugDemo = debugDemos.includes(hash.slice(1)); + useLayoutEffect(() => { - setShowDebug(process.env.NODE_ENV === 'development'); + setShowDebug(process.env.NODE_ENV === 'development' || isDebugDemo); }, []); const contextValue = useMemo(