-
-
Notifications
You must be signed in to change notification settings - Fork 722
/
blog-article-sharebar.tsx
87 lines (75 loc) · 1.82 KB
/
blog-article-sharebar.tsx
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
import { graphql } from "gatsby";
import React, { FC } from "react";
import { LinkedinShareButton, TwitterShareButton } from "react-share";
import styled from "styled-components";
import { BlogArticleSharebarFragment } from "@/graphql-types";
// Icons
import LinkedinIconSvg from "@/images/linkedin-square.svg";
import TwitterIconSvg from "@/images/twitter-square.svg";
export interface BlogArticleSharebarProps {
readonly data: BlogArticleSharebarFragment;
readonly tags: string[];
}
export const BlogArticleSharebar: FC<BlogArticleSharebarProps> = ({
data: { mdx, site },
tags,
}) => {
const { frontmatter } = mdx!;
const articelUrl = site!.siteMetadata!.siteUrl! + frontmatter!.path!;
const title = frontmatter!.title!;
return (
<ShareButtons>
<TwitterShareButton
url={articelUrl}
title={title}
via={site!.siteMetadata!.author!}
hashtags={tags}
>
<TwitterIcon />
</TwitterShareButton>
<LinkedinShareButton url={articelUrl} title={title}>
<LinkedinIcon />
</LinkedinShareButton>
</ShareButtons>
);
};
export const BlogArticleSharebarGraphQLFragment = graphql`
fragment BlogArticleSharebar on Query {
mdx(frontmatter: { path: { eq: $path } }) {
frontmatter {
path
tags
title
}
}
site {
siteMetadata {
author
siteUrl
}
}
}
`;
const ShareButtons = styled.aside`
position: fixed;
left: calc(50% - 480px);
display: none;
flex-direction: column;
padding: 150px 0 250px;
width: 60px;
> button {
flex: 0 0 50px;
> svg {
width: 30px;
}
}
@media only screen and (min-width: 992px) {
display: flex;
}
`;
const TwitterIcon = styled(TwitterIconSvg)`
fill: #1da0f2;
`;
const LinkedinIcon = styled(LinkedinIconSvg)`
fill: #0073b0;
`;