git ssb

0+

Rômulo Alves / website



Tree: 9a9e87b1ac89ee650b8ce508a34b0bc139f4ee83

Files: 9a9e87b1ac89ee650b8ce508a34b0bc139f4ee83 / components / post-link.js

1076 bytesRaw
1import Link from 'next/link';
2import ta from 'time-ago';
3import {
4 string,
5 bool
6} from 'prop-types';
7
8const PostLink = ({ href, date, lang, download, children }) => {
9 const link = (
10 <div className="post">
11 {
12 date && (
13 <span className="post-date">{
14 `${ta.ago(date)} (${date})`
15 }</span>
16 )
17 }
18 <a href={ href } title={ children } download={ download } className="post-title">
19 {
20 lang && `(${lang}) `
21 }
22 { children }
23 </a>
24
25 <style jsx global>{`
26 .post-date {
27 color: #757575;
28 display: block;
29 font-size: 16px;
30 margin-bottom: 2px;
31 }
32 .post-title {
33 font-size: 17px;
34 }
35 `}</style>
36 </div>
37 );
38
39 if (download) {
40 return link;
41 }
42
43 return (
44 <Link href={ href }>
45 { link }
46 </Link>
47 );
48};
49
50PostLink.propTypes = {
51 href: string.isRequired,
52 date: string,
53 lang: string,
54 download: bool
55};
56
57PostLink.defaultProps = {
58 download: false
59};
60
61export default PostLink;

Built with git-ssb-web