Skip to content

Commit 8ac636f

Browse files
committed
website: show contributors.
1 parent 3095357 commit 8ac636f

File tree

45 files changed

+193
-53
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+193
-53
lines changed

website/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "2.0.0",
44
"description": "Documentation site for React Native UIW.",
55
"homepage": "https://uiwjs.github.io/react-native-uiw",
6+
"type": "module",
67
"private": true,
78
"scripts": {
89
"start": "kkt start",
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
.warpper {
3+
padding: 18px 0;
4+
display: flex;
5+
}
6+
7+
.edit {
8+
display: flex;
9+
align-items: center;
10+
svg {
11+
margin-right: 5px;
12+
}
13+
}
14+
15+
.avatar {
16+
padding-left: 12px;
17+
a {
18+
display: flex;
19+
}
20+
img {
21+
width: 21px;
22+
}
23+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import styles from './index.module.less';
2+
import { useFetch } from '../../hook/useFetch'
3+
4+
type ContributorsProps = {
5+
path?: string
6+
}
7+
8+
export default function Contributors(props: ContributorsProps) {
9+
const { path } = props;
10+
if (!path) return null;
11+
return (
12+
<div className={styles.warpper}>
13+
<a className={styles.edit} href={`https://github.com/uiwjs/react-native-uiw/edit/master/${path.replace(/^\//, '')}`} target="__blank">
14+
<svg viewBox="0 0 1024 1024" width="14" height="14" fill="#757575">
15+
<path d="M837.818182 0H186.181818C134.981818 0 93.090909 41.890909 93.090909 93.090909v837.818182c0 51.2 41.890909 93.090909 93.090909 93.090909h651.636364c51.2 0 93.090909-41.890909 93.090909-93.090909V93.090909c0-51.2-41.890909-93.090909-93.090909-93.090909z m46.545454 912.290909c0 37.236364-27.927273 65.163636-65.163636 65.163636H204.8c-37.236364 0-65.163636-27.927273-65.163636-65.163636V111.709091C139.636364 74.472727 167.563636 46.545455 204.8 46.545455h614.4c37.236364 0 65.163636 27.927273 65.163636 65.163636v800.581818z" />
16+
<path d="M256 139.636364h418.909091c13.963636 0 23.272727 9.309091 23.272727 23.272727s-9.309091 23.272727-23.272727 23.272727h-418.909091c-13.963636 0-23.272727-9.309091-23.272727-23.272727s9.309091-23.272727 23.272727-23.272727zM256 279.272727h279.272727c13.963636 0 23.272727 9.309091 23.272728 23.272728s-9.309091 23.272727-23.272728 23.272727h-279.272727c-13.963636 0-23.272727-9.309091-23.272727-23.272727s9.309091-23.272727 23.272727-23.272728zM256 418.909091h139.636364c13.963636 0 23.272727 9.309091 23.272727 23.272727s-9.309091 23.272727-23.272727 23.272727h-139.636364c-13.963636 0-23.272727-9.309091-23.272727-23.272727s9.309091-23.272727 23.272727-23.272727z" />
17+
<path d="M256 581.818182m-23.272727 0a23.272727 23.272727 0 1 0 46.545454 0 23.272727 23.272727 0 1 0-46.545454 0Z" />
18+
<path d="M721.454545 558.545455h46.545455c13.963636 0 23.272727 9.309091 23.272727 23.272727s-9.309091 23.272727-23.272727 23.272727h-46.545455c-13.963636 0-23.272727-9.309091-23.272727-23.272727s9.309091-23.272727 23.272727-23.272727z" />
19+
<path d="M404.945455 768l-102.4-97.745455L781.963636 190.836364c27.927273-27.927273 69.818182-27.927273 97.745455 0s27.927273 69.818182 0 97.745454" />
20+
<path d="M339.781818 833.163636l-116.363636 18.618182 18.618182-116.363636 32.581818-32.581818L372.363636 800.581818" />
21+
</svg>
22+
在 GitHub 上编译此页
23+
</a>
24+
<AvatarList path={path}/>
25+
</div>
26+
)
27+
}
28+
29+
type Response = Array<{
30+
username: string;
31+
url: string;
32+
}>
33+
34+
function AvatarList(props: { path: string}) {
35+
const { path } = props;
36+
const fetchurl = `https://proapi.azurewebsites.net/doc/getAvatarList?filename=${path.replace(/^\//, '')}&owner=uiwjs&repo=react-native-uiw`;
37+
const res = useFetch<Response>(fetchurl);
38+
if (!res.response) {
39+
return <span className={styles.avatar}>Loading...</span>;
40+
}
41+
return (
42+
<span className={styles.avatar}>
43+
{res.response.map((item, idx) => {
44+
return (
45+
<a href={`https://github.com/${item.username}`} key={idx} target="__blank">
46+
<img src={item.url} alt={item.username} />
47+
</a>
48+
);
49+
})}
50+
</span>
51+
);
52+
}

website/src/component/Header/index.module.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
}
1111

1212
.inner {
13-
max-width: 1440px;
1413
margin: 0 auto;
1514
display: flex;
1615
justify-content: space-between;
@@ -35,6 +34,7 @@
3534
.logo {
3635
display: flex;
3736
align-items: center;
37+
color: #333;
3838
img {
3939
margin-right: 8px;
4040
height: 38px;

website/src/component/Header/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export default function Header() {
2626
<NavLink to="/components/">RN组件</NavLink>
2727
<a target="__blank" href="https://github.com/uiwjs/react-native-uiw/issues">问题反馈</a>
2828
<a target="__blank" href="https://uiwjs.github.io">Web 组件</a>
29+
<NavLink to="/team">团队</NavLink>
2930
<a target="__blank" href="https://github.com/uiwjs/react-native-uiw">GitHub</a>
3031
</div>
3132
</div>
Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +0,0 @@
1-
2-
3-
.edit {
4-
padding: 18px 0;
5-
}

website/src/component/Markdown/index.tsx

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import MarkdownPreview from '@uiw/react-markdown-preview';
33
// @ts-ignore
44
import rehypeAttr from 'rehype-attr';
55
import { useEffect } from 'react';
6+
import Contributors from '../Contributors';
67
import styles from './index.module.less';
78

89
export interface MarkdownProps extends React.HTMLAttributes<HTMLDivElement> {
@@ -13,18 +14,30 @@ export interface MarkdownProps extends React.HTMLAttributes<HTMLDivElement> {
1314
export default function Markdown(props: MarkdownProps) {
1415
const { renderPage, path, style } = props;
1516
const [mdStr, setMdStr] = useState('');
17+
const [message, setMessage] = useState('');
1618
useEffect(() => {
1719
if (renderPage) {
20+
setMessage('')
1821
renderPage()
1922
.then((str) => {
2023
setMdStr(str);
2124
})
22-
.catch(() => {});
25+
.catch(() => {
26+
setMessage('页面加载失败!请刷新页面')
27+
});
2328
}
2429
// eslint-disable-next-line react-hooks/exhaustive-deps
25-
}, [])
30+
}, []);
31+
if (message) {
32+
return (
33+
<div className={styles.warpper} style={style}>
34+
{message}
35+
<Contributors path={path}/>
36+
</div>
37+
);
38+
}
2639
return (
27-
<div style={style}>
40+
<div className={styles.warpper} style={style}>
2841
<MarkdownPreview
2942
source={mdStr}
3043
// className={styles.markdown}
@@ -52,11 +65,7 @@ export default function Markdown(props: MarkdownProps) {
5265
},
5366
}}
5467
/>
55-
{path && (
56-
<div className={styles.edit}>
57-
<a href={path}>Edit this page</a>
58-
</div>
59-
)}
68+
<Contributors path={path}/>
6069
</div>
6170
)
6271
}

website/src/hook/useFetch.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import React from 'react';
2+
3+
type UseFetchResult<F> = {
4+
error?: any;
5+
response?: F | null;
6+
}
7+
8+
export function useFetch<T>(url: string, options?: RequestInit): UseFetchResult<T> {
9+
const [response, setResponse] = React.useState(null);
10+
const [error, setError] = React.useState(null);
11+
12+
React.useEffect(() => {
13+
const fetchData = async () => {
14+
try {
15+
const res = await fetch(url, options);
16+
const json = await res.json();
17+
setResponse(json);
18+
} catch (error) {
19+
setError(error);
20+
}
21+
};
22+
fetchData();
23+
// eslint-disable-next-line react-hooks/exhaustive-deps
24+
}, []);
25+
26+
return { response, error };
27+
}

website/src/pages/components/about/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import React from 'react';
21
import { DefaultProps } from '../../../';
32
import Markdown from '../../../component/Markdown';
43

54
export default function Page(props: DefaultProps) {
65
return (
76
<Markdown
8-
path="https://github.com/uiwjs/react-native-uiw/edit/master/packages/core/README.md"
7+
path="/packages/core/README.md"
98
renderPage={async () => {
109
const md = await import('@uiw/react-native/README.md');
1110
return md.default || md;

website/src/pages/components/avatar/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Markdown from '../../../component/Markdown';
55
export default function Page(props: DefaultProps) {
66
return (
77
<Markdown
8-
path="https://github.com/uiwjs/react-native-uiw/edit/master/packages/core/src/Avatar/README.md"
8+
path="/packages/core/src/Avatar/README.md"
99
renderPage={async () => {
1010
const md = await import('@uiw/react-native/lib/Avatar/README.md');
1111
return md.default || md;

0 commit comments

Comments
 (0)