portfolio/src/components/Repository/index.tsx

48 lines
1.3 KiB
TypeScript
Raw Normal View History

2024-02-05 10:29:00 +01:00
import Repo from '@/types/repo'
import Icon from '../Icon'
import styles from './index.module.css'
2019-05-26 16:55:56 +02:00
export default function Repository({ repo }: { repo: Repo }) {
2021-05-23 12:30:39 +02:00
const { name, full_name, description, html_url, homepage, stargazers_count } =
repo
2019-10-10 00:40:57 +02:00
const isExternal = !full_name.includes('kremalicious')
2019-05-26 16:55:56 +02:00
// for blog & portfolio and if there's no homepage, use github url
// else use homepage field
const repoLink =
2019-10-10 00:40:57 +02:00
name === 'blog' || name === 'portfolio' || !homepage || isExternal
? html_url
: homepage
2019-05-26 16:55:56 +02:00
return (
<div className={styles.repo}>
2022-11-18 00:46:24 +01:00
<h3 className={styles.repoTitle}>
2019-10-10 00:40:57 +02:00
<a href={repoLink}>{isExternal ? full_name : name}</a>
2022-11-18 00:46:24 +01:00
</h3>
2019-05-26 16:55:56 +02:00
<p>{description}</p>
<p className={styles.meta}>
2019-05-26 16:55:56 +02:00
{name === 'portfolio' || name === 'blog'
? null
2019-10-10 00:40:57 +02:00
: !isExternal &&
homepage && (
2019-06-10 19:02:58 +02:00
<a href={homepage}>
2019-11-13 13:32:11 +01:00
<Icon name="Compass" /> More info
2019-05-26 16:55:56 +02:00
</a>
)}
<a href={html_url}>
2019-11-13 13:32:11 +01:00
<Icon name="GitHub" /> GitHub
2019-05-26 16:55:56 +02:00
</a>
2022-11-18 00:46:24 +01:00
<a
aria-label={`${stargazers_count} stars`}
href={`${html_url}/stargazers`}
>
2019-11-13 13:32:11 +01:00
<Icon name="Star" /> {stargazers_count}
2019-05-26 16:55:56 +02:00
</a>
</p>
</div>
)
}