-
Notifications
You must be signed in to change notification settings - Fork 7
/
bio.js
99 lines (92 loc) · 2.25 KB
/
bio.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/**
* Bio component that queries for data
* with Gatsby's useStaticQuery component
*
* See: https://www.gatsbyjs.org/docs/use-static-query/
*/
import React from "react"
import { useStaticQuery, graphql, Link } from "gatsby"
import { rhythm } from "../utils/typography"
import { authors } from "../globals"
const Bio = ({author: postWriter = ''}) => {
const data = useStaticQuery(graphql`
query BioQuery {
site {
siteMetadata {
author
social {
twitter
}
}
}
}
`)
let author = {
slug: '',
name: '',
twitter: '',
drupal: ''
};
if (authors[postWriter]) {
author.name = authors[postWriter].name;
author.slug = postWriter;
author.twitter = authors[postWriter].twitter;
author.drupal = authors[postWriter].drupal;
author.bio = authors[postWriter].bio;
} else {
const { author: blogWriter, social } = data.site.siteMetadata;
author.name = blogWriter;
author.slug = 'trishul';
author.twitter = social.twitter;
author.drupal = social.drupal;
}
return (
<div
style={{
display: `flex`,
marginBottom: rhythm(2.5),
}}
>
<Link
to={`/author/${author.slug}`}
style={{
minWidth: 50,
minHeight: 50,
marginRight: rhythm(1 / 2),
marginBottom: 0,
overflow: `hidden`,
boxShadow: 'none'
}}
>
<img
alt={author.name}
style={{
width: 50,
height: `auto`,
borderRadius: `100%`,
}}
src={`/${author.slug}.jpg`}
/>
</Link>
<p>
<strong>{author.name}</strong> {author.bio}.
<br/>
{
(author.twitter && author.twitter !== "") ?
(<a target="_blank" rel="noopener noreferrer" href={`https://twitter.com/${author.twitter}`}>
@{author.twitter}
</a>):
null
}
{
(author.drupal && author.drupal !== "") ?
(<div> Drupal Profile: <a target="_blank" rel="noopener noreferrer" href={`https://drupal.org/u/${author.drupal}`}>
{author.drupal}</a>
</div>):
null
}
</p>
</div>
)
}
export default Bio