2019-12-26 15:27:52 +08:00
|
|
|
import * as React from 'react';
|
|
|
|
import { FormattedMessage, useIntl } from 'react-intl';
|
|
|
|
import { Typography } from 'antd';
|
|
|
|
import { Link } from 'bisheng/router';
|
|
|
|
import Banner from './Banner';
|
|
|
|
import RecommendPage from './RecommendPage';
|
|
|
|
import DesignPage from './DesignPage';
|
|
|
|
import MorePage from './MorePage';
|
|
|
|
import Footer from '../Layout/Footer';
|
|
|
|
import { getLocalizedPathname } from '../utils';
|
|
|
|
import './index.less';
|
|
|
|
|
|
|
|
const { Title } = Typography;
|
|
|
|
|
|
|
|
function getStyle() {
|
|
|
|
return `
|
|
|
|
.rc-footer-container {
|
|
|
|
padding-left: 0;
|
|
|
|
padding-right: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.rc-footer-columns {
|
|
|
|
max-width: 1208px;
|
|
|
|
margin: 0 auto;
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface BlockContentProps {
|
|
|
|
title: React.ReactNode;
|
|
|
|
extra?: React.ReactNode;
|
2022-04-08 22:55:42 +08:00
|
|
|
children?: React.ReactNode;
|
2019-12-26 15:27:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const BlockContent: React.FC<BlockContentProps> = ({ title, children, extra }) => (
|
|
|
|
<div className="home-block-content">
|
|
|
|
<Title level={2} style={{ fontWeight: 'lighter', color: '#314659' }}>
|
|
|
|
{title}
|
|
|
|
|
2020-01-03 15:20:10 +08:00
|
|
|
{extra && <div className="home-block-content-extra">{extra}</div>}
|
2019-12-26 15:27:52 +08:00
|
|
|
</Title>
|
|
|
|
{children}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
|
2020-09-14 10:48:08 +08:00
|
|
|
const Home = (props: { location: any }) => {
|
|
|
|
const { location } = props;
|
2019-12-26 15:27:52 +08:00
|
|
|
const { locale } = useIntl();
|
|
|
|
const isZhCN = locale === 'zh-CN';
|
|
|
|
|
2020-09-14 10:48:08 +08:00
|
|
|
const getLink = () => {
|
|
|
|
const path = getLocalizedPathname('/docs/resources', isZhCN, location.query, {
|
|
|
|
zhCN: '文章',
|
|
|
|
enUS: 'Articles',
|
|
|
|
});
|
2021-11-26 12:18:21 +08:00
|
|
|
const { pathname, query = {} } = path;
|
2020-09-14 10:48:08 +08:00
|
|
|
const pathnames = pathname.split('#');
|
|
|
|
if ('direction' in query) {
|
|
|
|
return `${pathnames[0]}?direction=rtl#${pathnames[1]}`;
|
|
|
|
}
|
|
|
|
return path;
|
|
|
|
};
|
|
|
|
|
2019-12-26 15:27:52 +08:00
|
|
|
return (
|
|
|
|
<div className="home-container">
|
2020-04-03 15:02:11 +08:00
|
|
|
<style dangerouslySetInnerHTML={{ __html: getStyle() }} />
|
2020-09-14 10:48:08 +08:00
|
|
|
<Banner location={location} />
|
2019-12-26 15:27:52 +08:00
|
|
|
<div style={{ maxWidth: 1256, margin: '0 auto' }}>
|
|
|
|
<BlockContent title={<FormattedMessage id="app.home.recommend" />}>
|
|
|
|
<RecommendPage />
|
|
|
|
</BlockContent>
|
|
|
|
|
|
|
|
<BlockContent title={<FormattedMessage id="app.home.design-and-framework" />}>
|
2020-09-14 10:48:08 +08:00
|
|
|
<DesignPage location={location} />
|
2019-12-26 15:27:52 +08:00
|
|
|
</BlockContent>
|
|
|
|
|
2020-12-04 14:24:49 +08:00
|
|
|
<BlockContent
|
|
|
|
title={<FormattedMessage id="app.home.more" />}
|
|
|
|
extra={
|
|
|
|
<Link to={getLink()} target="_blank">
|
|
|
|
<FormattedMessage id="app.home.view-more" />
|
|
|
|
</Link>
|
|
|
|
}
|
|
|
|
>
|
|
|
|
<MorePage />
|
|
|
|
</BlockContent>
|
2019-12-26 15:27:52 +08:00
|
|
|
</div>
|
2020-09-14 10:48:08 +08:00
|
|
|
<Footer location={location} />
|
2019-12-26 15:27:52 +08:00
|
|
|
</div>
|
|
|
|
);
|
2020-09-14 10:48:08 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
export default Home;
|