import React, { useContext, useLayoutEffect, useMemo } from 'react'; import { Col, Flex, 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 ComponentMeta from '../../builtins/ComponentMeta'; import type { DemoContextProps } from '../DemoContext'; import DemoContext from '../DemoContext'; import SiteContext from '../SiteContext'; import InViewSuspense from './InViewSuspense'; 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 ${token.paddingLG * 2}px; } } `, })); 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} {/* Import Info */} {meta.frontmatter.category === 'Components' && String(meta.frontmatter.showImport) !== 'false' && ( )}
{children}
}>