Browse Source

site: add zhihu & yuque column card (#43122)

* site: add zhihu card

* fix

* fix

* fix

* Update .dumi/theme/slots/Content/ZhihuCard.tsx

Co-authored-by: afc163 <afc163@gmail.com>

* fix

* fix

* fix

* Update basic.tsx

* Update .dumi/theme/slots/Content/ZhihuCard.tsx

Co-authored-by: afc163 <afc163@gmail.com>

* fix

* update style

* fix

* fix

* fix: rename

* update

* update

* update url

---------

Co-authored-by: afc163 <afc163@gmail.com>
pull/42825/merge
lijianan 1 year ago
committed by GitHub
parent
commit
c01972edb2
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 188
      .dumi/theme/slots/Content/ColumnCard.tsx
  2. 7
      .dumi/theme/slots/Content/index.tsx
  3. 1
      docs/blog/why-not-static.en-US.md
  4. 1
      docs/blog/why-not-static.zh-CN.md

188
.dumi/theme/slots/Content/ColumnCard.tsx

@ -0,0 +1,188 @@
import { RightOutlined, YuqueOutlined, ZhihuOutlined } from '@ant-design/icons';
import { css } from '@emotion/react';
import { Button, Card, Divider } from 'antd';
import React from 'react';
import useLocale from '../../../hooks/useLocale';
import useSiteToken from '../../../hooks/useSiteToken';
const ANTD_IMG_URL =
'https://picx.zhimg.com/v2-3b2bca09c2771e7a82a81562e806be4d.jpg?source=d16d100b';
const useStyle = () => {
const { token } = useSiteToken();
return {
card: css`
width: 100%;
margin: 40px 0;
transition: all 0.2s;
background-color: ${token.colorFillQuaternary};
`,
bigTitle: css`
font-size: 16px;
color: #121212;
margin-bottom: 24px;
font-weight: 600;
`,
cardBody: css`
display: flex;
justify-content: space-between;
align-items: center;
`,
left: css`
display: flex;
justify-content: flex-start;
align-items: center;
img {
width: 200px;
margin-right: 24px;
overflow: hidden;
border-radius: 8px;
}
`,
title: css`
color: #444;
font-size: 16px;
font-weight: 600;
`,
subTitle: css`
display: flex;
justify-content: flex-start;
align-items: center;
color: #646464;
font-size: 14px;
font-weight: 400;
margin-top: 8px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
.logo {
font-size: 24px;
&.zhihu-logo {
color: #056de8;
}
&.yuque-logo {
color: #00b96b;
}
}
.arrowIcon {
margin: 0 8px;
color: #8a8f8d;
font-size: 12px;
}
.zl-btn {
display: flex;
align-items: center;
justify-content: center;
padding: 0;
color: #646464;
}
`,
btn: css`
display: flex;
justify-content: center;
align-items: center;
`,
};
};
const locales = {
cn: {
bigTitle: '文章被以下专栏收录:',
zhiHu: '一个 UI 设计体系',
yuQue: 'Ant Design 官方专栏',
buttonText: '我有想法,去参与讨论',
},
en: {
bigTitle: 'Articles are included in the column:',
zhiHu: 'A UI design system',
yuQue: 'Ant Design official column',
buttonText: 'Go to discuss',
},
};
interface Props {
zhihuLink?: string;
yuqueLink?: string;
}
const ColumnCard: React.FC<Props> = ({ zhihuLink, yuqueLink }) => {
const [locale] = useLocale(locales);
const { card, bigTitle, cardBody, left, title, subTitle, btn } = useStyle();
if (!zhihuLink && !yuqueLink) {
return null;
}
return (
<Card css={card} bordered={false}>
<h3 css={bigTitle}>{locale.bigTitle}</h3>
{zhihuLink && (
<div css={cardBody}>
<div css={left}>
<img src={ANTD_IMG_URL} alt="antd" />
<div>
<p css={title}>Ant Design</p>
<div css={subTitle}>
<ZhihuOutlined className="logo zhihu-logo" />
<RightOutlined className="arrowIcon" />
<Button
target="_blank"
href="https://www.zhihu.com/column/c_1564262000561106944"
className="zl-btn"
type="link"
>
{locale.zhiHu}
</Button>
</div>
</div>
</div>
<Button
type="primary"
css={btn}
icon={<ZhihuOutlined style={{ fontSize: 15 }} />}
ghost
target="_blank"
href={zhihuLink}
>
{locale.buttonText}
</Button>
</div>
)}
{yuqueLink && (
<>
<Divider />
<div css={cardBody}>
<div css={left}>
<img src={ANTD_IMG_URL} alt="antd" />
<div>
<p css={title}>Ant Design</p>
<div css={subTitle}>
<YuqueOutlined className="logo yuque-logo" />
<RightOutlined className="arrowIcon" />
<Button
target="_blank"
href="https://www.yuque.com/ant-design/ant-design"
className="zl-btn"
type="link"
>
{locale.yuQue}
</Button>
</div>
</div>
</div>
<Button
type="primary"
css={btn}
icon={<YuqueOutlined style={{ fontSize: 15 }} />}
ghost
target="_blank"
href={yuqueLink}
>
{locale.buttonText}
</Button>
</div>
</>
)}
</Card>
);
};
export default ColumnCard;

7
.dumi/theme/slots/Content/index.tsx

@ -16,6 +16,7 @@ import type { DemoContextProps } from '../DemoContext';
import DemoContext from '../DemoContext';
import Footer from '../Footer';
import SiteContext from '../SiteContext';
import ColumnCard from './ColumnCard';
const useStyle = () => {
const { token } = useSiteToken();
@ -272,6 +273,12 @@ const Content: React.FC<{ children: ReactNode }> = ({ children }) => {
) : null}
{!meta.frontmatter.__autoDescription && meta.frontmatter.description}
{children}
{(meta.frontmatter?.zhihu_url || meta.frontmatter?.yuque_url) && (
<ColumnCard
zhihuLink={meta.frontmatter.zhihu_url}
yuqueLink={meta.frontmatter.yuque_url}
/>
)}
{meta.frontmatter.filename && (
<ContributorsList
repo="ant-design"

1
docs/blog/why-not-static.en-US.md

@ -2,6 +2,7 @@
title: Pain of static methods
date: 2023-04-26
author: zombieJ
zhihu_url: https://zhuanlan.zhihu.com/p/633333904
---
> `message.success` is working well, why do you warn me to use hooks? antd is getting worse and worse, goodbye!

1
docs/blog/why-not-static.zh-CN.md

@ -2,6 +2,7 @@
title: 静态方法之痛
date: 2023-04-26
author: zombieJ
zhihu_url: https://zhuanlan.zhihu.com/p/633333904
---
> `message.success` 用的好好的为什么要 warning 我去用 hooks?antd 越做越垃圾,走好不送!

Loading…
Cancel
Save