import React, { Suspense, useContext, useLayoutEffect, useMemo } from 'react'; import { Col, Skeleton, Space, Typography } from 'antd'; import { createStyles } from 'antd-style'; import classNames from 'classnames'; import { FormattedMessage, useRouteMeta } from 'dumi'; import useLayoutState from '../../../hooks/useLayoutState'; import useLocation from '../../../hooks/useLocation'; import type { DemoContextProps } from '../DemoContext'; import DemoContext from '../DemoContext'; import SiteContext from '../SiteContext'; const Contributors = React.lazy(() => import('./Contributors')); const ColumnCard = React.lazy(() => import('./ColumnCard')); const DocAnchor = React.lazy(() => import('./DocAnchor')); const DocMeta = React.lazy(() => import('./DocMeta')); const Footer = React.lazy(() => import('../Footer')); const PrevAndNext = React.lazy(() => import('../../common/PrevAndNext')); const ComponentChangelog = React.lazy(() => import('../../common/ComponentChangelog')); const EditButton = React.lazy(() => import('../../common/EditButton')); const useStyle = createStyles(({ token, css }) => ({ articleWrapper: css` padding: 0 170px 32px 64px; &.rtl { padding: 0 64px 144px 170px; } @media only screen and (max-width: ${token.screenLG}px) { &, &.rtl { padding: 0 48px; } } `, })); const Content: React.FC = ({ children }) => { const meta = useRouteMeta(); const { pathname, hash } = useLocation(); const { direction } = useContext(SiteContext); const { styles } = useStyle(); const [showDebug, setShowDebug] = useLayoutState(false); const debugDemos = useMemo( () => meta.toc?.filter((item) => item._debug_demo).map((item) => item.id) || [], [meta], ); const isDebugDemo = debugDemos.includes(hash.slice(1)); useLayoutEffect(() => { setShowDebug(process.env.NODE_ENV === 'development' || isDebugDemo); }, []); const contextValue = useMemo( () => ({ showDebug, setShowDebug }), [showDebug, debugDemos], ); const isRTL = direction === 'rtl'; return ( }>
{meta.frontmatter?.title ? ( {meta.frontmatter?.title} {meta.frontmatter?.subtitle} {!pathname.startsWith('/components/overview') && ( } filename={meta.frontmatter.filename} /> )} {pathname.startsWith('/components/') && ( )} ) : null} }> {!meta.frontmatter.__autoDescription && meta.frontmatter.description}
{children}
}> }>
}>