ant-design/site/theme/template/Home/index.tsx
dependabot[bot] 20d5502193
chore(deps-dev): bump eslint-config-airbnb from 18.2.1 to 19.0.0 (#32824)
* chore(deps-dev): bump eslint-config-airbnb from 18.2.1 to 19.0.0

Bumps [eslint-config-airbnb](https://github.com/airbnb/javascript) from 18.2.1 to 19.0.0.
- [Release notes](https://github.com/airbnb/javascript/releases)
- [Commits](https://github.com/airbnb/javascript/compare/eslint-config-airbnb-v18.2.1...eslint-config-airbnb-v19.0.0)

---
updated-dependencies:
- dependency-name: eslint-config-airbnb
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* fix lint

* fix lint

* fix lint

* fix lint

* fix lint

* fix lint

* fix lint

* fix lint

* fix lint

* chore: code style

* memoize-one

* add comment

* fix lint

* fix lint

* fix lint

* fix lint

* fix lint

* fix lint

* fix lint

* fix lint

* fix lint

* improve useMemo deps

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: afc163 <afc163@gmail.com>
2021-11-26 12:18:21 +08:00

93 lines
2.4 KiB
TypeScript

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;
}
const BlockContent: React.FC<BlockContentProps> = ({ title, children, extra }) => (
<div className="home-block-content">
<Title level={2} style={{ fontWeight: 'lighter', color: '#314659' }}>
{title}
{extra && <div className="home-block-content-extra">{extra}</div>}
</Title>
{children}
</div>
);
const Home = (props: { location: any }) => {
const { location } = props;
const { locale } = useIntl();
const isZhCN = locale === 'zh-CN';
const getLink = () => {
const path = getLocalizedPathname('/docs/resources', isZhCN, location.query, {
zhCN: '文章',
enUS: 'Articles',
});
const { pathname, query = {} } = path;
const pathnames = pathname.split('#');
if ('direction' in query) {
return `${pathnames[0]}?direction=rtl#${pathnames[1]}`;
}
return path;
};
return (
<div className="home-container">
<style dangerouslySetInnerHTML={{ __html: getStyle() }} />
<Banner location={location} />
<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" />}>
<DesignPage location={location} />
</BlockContent>
<BlockContent
title={<FormattedMessage id="app.home.more" />}
extra={
<Link to={getLink()} target="_blank">
<FormattedMessage id="app.home.view-more" />
</Link>
}
>
<MorePage />
</BlockContent>
</div>
<Footer location={location} />
</div>
);
};
export default Home;