1
0
mirror of https://github.com/kremalicious/blog.git synced 2024-06-30 13:41:54 +02:00
blog/src/components/molecules/Networks.tsx

38 lines
847 B
TypeScript
Raw Normal View History

2020-05-22 14:38:19 +02:00
import React, { ReactElement } from 'react'
2019-11-15 22:10:53 +01:00
import Icon from '../atoms/Icon'
import * as styles from './Networks.module.css'
2019-10-02 13:35:50 +02:00
function NetworkIcon({ link }: { link: string }) {
2019-11-15 22:10:53 +01:00
let IconComp
2019-10-02 13:35:50 +02:00
if (link.includes('twitter')) {
2019-11-15 22:10:53 +01:00
IconComp = <Icon name="Twitter" />
2019-10-02 13:35:50 +02:00
} else if (link.includes('github')) {
2019-11-15 22:10:53 +01:00
IconComp = <Icon name="GitHub" />
2019-10-02 13:35:50 +02:00
} else if (link.includes('feed.xml')) {
2019-11-15 22:10:53 +01:00
IconComp = <Icon name="Rss" />
2019-10-02 13:35:50 +02:00
} else if (link.includes('feed.json')) {
2019-11-15 22:10:53 +01:00
IconComp = <Icon name="Jsonfeed" />
2019-10-13 19:08:36 +02:00
} else {
return null
2019-10-02 13:35:50 +02:00
}
2019-11-15 22:10:53 +01:00
return IconComp
2019-10-02 13:35:50 +02:00
}
2020-05-22 14:38:19 +02:00
export default function IconLinks({
links
}: {
links: string[]
}): ReactElement {
2019-10-02 13:35:50 +02:00
return (
<p>
{links.map((link: string) => (
<a key={link} className={styles.link} href={link} title={link}>
2019-10-02 13:35:50 +02:00
<NetworkIcon link={link} />
</a>
))}
</p>
)
}