diff --git a/.circleci/config.yml b/.circleci/config.yml index 23d7c75..8c7d045 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,6 +1,6 @@ version: 2 jobs: - docs: + lint: docker: - image: circleci/node:12.0 @@ -21,7 +21,7 @@ jobs: - node_modules key: v2-dependencies-{{ checksum "package.json" }} - - run: yarn run now-build + - run: yarn run lint build: docker: @@ -49,5 +49,5 @@ workflows: version: 2 build_and_test: jobs: - - docs + - lint - build diff --git a/.nowignore b/.nowignore new file mode 100644 index 0000000..411ea2b --- /dev/null +++ b/.nowignore @@ -0,0 +1,6 @@ +.idea +.git +.DS_Store +.env +examples +.circleci diff --git a/lib/components/attributes/attributes.tsx b/lib/components/attributes/attributes.tsx index d82f5fe..7e9d44a 100644 --- a/lib/components/attributes/attributes.tsx +++ b/lib/components/attributes/attributes.tsx @@ -1,20 +1,35 @@ import React, { useMemo } from 'react' -import { Card, Link, Spacer, useTheme } from 'components' +import { Card, Link, Spacer, Avatar, Tooltip, useTheme } from 'components' import AttributesTitle from './attributes-title' import VirtualAnchor from 'lib/components/anchor' import { useConfigs } from '../../config-context' +import ContributorMetadatas from 'lib/data/contributors.json' +const GithubURL = 'https://github.com/zeit-ui/react/blob/master' export interface AttributesProps { edit: string } +export interface Contributor { + name: string + avatar: string + url: string +} + +export type ContributorMeta = { + [key: string]: Array +} + const Attributes: React.FC> = React.memo(({ edit, children, }) => { const theme = useTheme() const { isChinese } = useConfigs() - const link = useMemo(() => { - return `https://github.com/zeit-ui/react/blob/master${edit || '/pages'}` + const link = useMemo(() => `${GithubURL}${edit || '/pages'}`, []) + const contributors = useMemo(() => { + const key = edit.replace('/pages', 'pages') + const users = (ContributorMetadatas as ContributorMeta)[key] + return users || [] }, []) return ( @@ -24,10 +39,22 @@ const Attributes: React.FC> = React.mem {children} - - - {isChinese ? '在 GitHub 上编辑此页面' : 'Edit this page on GitHub'} - + +

{isChinese ? '文档贡献者' : 'Contributors'}

+
+ {contributors.map((user, index) => ( + {user.name}} key={`${user.url}-${index}`}> + + + + + ))} + + + + + +