|
1 | 1 | // Copyright 2023 DatabendLabs.
|
2 |
| -import React, { FC, ReactElement } from 'react'; |
3 |
| -import Link from '@docusaurus/Link'; |
4 |
| -import * as icons from "../Icons" |
5 |
| -import useGetReleases from '@site/src/hooks/useGetReleases'; |
6 |
| -import clsx from 'clsx'; |
7 |
| -import styles from './styles.module.scss'; |
8 |
| -import $t from '@site/src/utils/tools'; |
| 2 | +import React, { FC, ReactElement } from "react"; |
| 3 | +import Link from "@docusaurus/Link"; |
| 4 | +import useGetReleases from "@site/src/hooks/useGetReleases"; |
| 5 | +import clsx from "clsx"; |
| 6 | +import styles from "./styles.module.scss"; |
| 7 | +import $t from "@site/src/utils/tools"; |
| 8 | +import useDocusaurusContext from "@docusaurus/useDocusaurusContext"; |
| 9 | +import GitHub from "../Icons/gitHub.svg"; |
| 10 | +import Zhihu from "../Icons/zhihu.svg"; |
| 11 | +import OSChina from "../Icons/os-china.svg"; |
| 12 | +import X from "../Icons/x.svg"; |
| 13 | +import Slack from "../Icons/slack.svg"; |
| 14 | +import YouTube from "../Icons/youtube.svg"; |
| 15 | +import Bili from "../Icons/bili.svg"; |
| 16 | +import GongzhonghaoImg from "@site/static/img/databend-gongzhonghao.jpeg"; |
| 17 | +import LittleDImg from "@site/static/img/little-d.jpeg"; |
| 18 | +import { Tooltip } from "antd"; |
9 | 19 | interface TProps {
|
10 |
| - titleAlign?: 'start' | 'end' | 'left' | 'right' | 'center' | 'justify' | 'match-parent'; |
| 20 | + titleAlign?: |
| 21 | + | "start" |
| 22 | + | "end" |
| 23 | + | "left" |
| 24 | + | "right" |
| 25 | + | "center" |
| 26 | + | "justify" |
| 27 | + | "match-parent"; |
11 | 28 | maxWidth?: number;
|
12 |
| - justifyContent?: 'center' | 'flex-start' | 'flex-end'; |
| 29 | + justifyContent?: "center" | "flex-start" | "flex-end"; |
13 | 30 | }
|
14 | 31 |
|
15 |
| -const JoinCommunity: FC<TProps> = ({ titleAlign, maxWidth, justifyContent }): ReactElement => { |
16 |
| - const { formatStargazersCount } = useGetReleases(); |
17 |
| - const community = [ |
18 |
| - { |
19 |
| - 'icon': 'GitHub', |
20 |
| - 'star': formatStargazersCount, |
21 |
| - 'title': 'GitHub', |
22 |
| - 'link': 'https://github.com/datafuselabs/databend' |
23 |
| - }, |
24 |
| - { |
25 |
| - 'icon': 'Slack', |
26 |
| - 'title': 'Slack', |
27 |
| - 'link': 'https://link.databend.com/join-slack' |
| 32 | +const JoinCommunity: FC<TProps> = ({ |
| 33 | + titleAlign = "center", |
| 34 | + maxWidth = 720, |
| 35 | + justifyContent = "center", |
| 36 | +}): ReactElement => { |
| 37 | + const { |
| 38 | + siteConfig: { |
| 39 | + customFields: { isChina }, |
28 | 40 | },
|
| 41 | + } = useDocusaurusContext() as any; |
| 42 | + const { formatStargazersCount } = useGetReleases(); |
| 43 | + const community = isChina |
| 44 | + ? [ |
| 45 | + { |
| 46 | + icon: <GitHub />, |
| 47 | + star: formatStargazersCount, |
| 48 | + title: "GitHub", |
| 49 | + link: "https://github.com/datafuselabs/databend", |
| 50 | + }, |
| 51 | + { |
| 52 | + icon: <Zhihu />, |
| 53 | + title: "知乎", |
| 54 | + link: "https://www.zhihu.com/org/datafuse", |
| 55 | + }, |
| 56 | + { |
| 57 | + icon: <Bili />, |
| 58 | + title: "bilibili", |
| 59 | + link: "https://space.bilibili.com/275673537", |
| 60 | + }, |
| 61 | + { |
| 62 | + icon: <OSChina />, |
| 63 | + title: "开源中国", |
| 64 | + link: "https://my.oschina.net/u/5489811", |
| 65 | + }, |
| 66 | + ] |
| 67 | + : [ |
| 68 | + { |
| 69 | + icon: <GitHub />, |
| 70 | + star: formatStargazersCount, |
| 71 | + title: "GitHub", |
| 72 | + link: "https://github.com/datafuselabs/databend", |
| 73 | + }, |
| 74 | + { |
| 75 | + icon: <Slack />, |
| 76 | + title: "Slack", |
| 77 | + link: "https://link.databend.com/join-slack", |
| 78 | + }, |
| 79 | + { |
| 80 | + icon: <X />, |
| 81 | + title: "Twitter", |
| 82 | + link: "https://twitter.com/DatabendLabs", |
| 83 | + }, |
| 84 | + { |
| 85 | + icon: <YouTube />, |
| 86 | + title: "YouTube", |
| 87 | + link: "https://www.youtube.com/@DatabendLabs", |
| 88 | + }, |
| 89 | + ]; |
| 90 | + const QRCode = [ |
29 | 91 | {
|
30 |
| - 'icon': 'Twitter', |
31 |
| - 'title': 'Twitter', |
32 |
| - 'link': 'https://twitter.com/DatabendLabs' |
| 92 | + title: "Databend 公众号", |
| 93 | + icon: <img style={{ borderRadius: "6px" }} src={GongzhonghaoImg}></img>, |
33 | 94 | },
|
34 | 95 | {
|
35 |
| - 'icon': 'YouTube', |
36 |
| - 'title': 'YouTube', |
37 |
| - 'link': 'https://www.youtube.com/@DatabendLabs' |
| 96 | + title: "客服小 D", |
| 97 | + icon: <img style={{ borderRadius: "6px" }} src={LittleDImg}></img>, |
38 | 98 | },
|
39 |
| - ] |
| 99 | + ]; |
40 | 100 | return (
|
41 |
| - <div className={clsx('community', styles.Community)}> |
42 |
| - <h6 style={{ textAlign: titleAlign }}>{$t('Join our growing community')}</h6> |
43 |
| - <div className={clsx('community-group', styles.CommunityGroup)} style={{ maxWidth: maxWidth + 'px', justifyContent }}> |
| 101 | + <div className={clsx("community", styles.Community)}> |
| 102 | + <h6 style={{ textAlign: titleAlign }}> |
| 103 | + {$t("Join our growing community")} |
| 104 | + </h6> |
| 105 | + <div |
| 106 | + className={clsx("community-group", styles.CommunityGroup)} |
| 107 | + style={{ maxWidth: maxWidth + "px", justifyContent }} |
| 108 | + > |
44 | 109 | {community.map((item, index) => {
|
45 |
| - const Icon = (icons as any)[item.icon] |
46 |
| - return <Link to={item.link} key={index}> |
47 |
| - <div className={clsx('community-item', styles.communityItem)}><div className={clsx('icon', styles.Icon)}><Icon size={24} /></div><h6>{item.title}</h6>{item.star ? <span className={clsx('tag', styles.tag)}>🌟 {item.star} Stars</span> : ''}</div> |
48 |
| - </Link> |
| 110 | + return ( |
| 111 | + <Link to={item.link} key={index}> |
| 112 | + <div className={clsx("community-item", styles.communityItem)}> |
| 113 | + <div className={clsx("icon", styles.Icon)}>{item.icon}</div> |
| 114 | + <h6>{item.title}</h6> |
| 115 | + {item.star ? ( |
| 116 | + <span className={clsx("tag", styles.tag)}> |
| 117 | + 🌟 {item.star} Stars |
| 118 | + </span> |
| 119 | + ) : ( |
| 120 | + "" |
| 121 | + )} |
| 122 | + </div> |
| 123 | + </Link> |
| 124 | + ); |
49 | 125 | })}
|
| 126 | + {isChina && ( |
| 127 | + <div> |
| 128 | + <div style={{ marginBottom: "8px", fontSize: "13px" }}>微信</div> |
| 129 | + <div className={clsx("community-group", styles.CommunityGroup)}> |
| 130 | + {QRCode?.map((code, index) => { |
| 131 | + return ( |
| 132 | + <Tooltip key={index} title={code.title}> |
| 133 | + <div |
| 134 | + style={{ |
| 135 | + width: "157px", |
| 136 | + border: "1px solid var(--color-border)", |
| 137 | + cursor: "zoom-in", |
| 138 | + borderRadius: "6px", |
| 139 | + }} |
| 140 | + > |
| 141 | + {code.icon} |
| 142 | + </div> |
| 143 | + </Tooltip> |
| 144 | + ); |
| 145 | + })} |
| 146 | + </div> |
| 147 | + </div> |
| 148 | + )} |
50 | 149 | </div>
|
51 | 150 | </div>
|
52 | 151 | );
|
53 | 152 | };
|
54 |
| -JoinCommunity.defaultProps = { |
55 |
| - titleAlign: 'center', |
56 |
| - maxWidth: 720, |
57 |
| - justifyContent: 'center' |
58 |
| -} |
59 | 153 | export default JoinCommunity;
|
0 commit comments