-
-
Notifications
You must be signed in to change notification settings - Fork 773
/
Copy pathblog-article-teaser-metadata.tsx
93 lines (83 loc) · 1.87 KB
/
blog-article-teaser-metadata.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
88
89
90
91
92
93
import { graphql } from "gatsby";
import React, { FC } from "react";
import styled from "styled-components";
import { BlogArticleTeaserMetadataFragment } from "@/graphql-types";
import { THEME_COLORS } from "@/style";
export interface BlogArticleTeaserMetadataProps {
readonly data: BlogArticleTeaserMetadataFragment;
}
export const BlogArticleTeaserMetadata: FC<BlogArticleTeaserMetadataProps> = ({
data: { fields, frontmatter },
}) => {
return (
<Metadata>
<Author>
<AuthorImage src={frontmatter!.authorImageUrl!} />
{frontmatter!.author!}
</Author>
<Space>
<Title>{frontmatter!.title}</Title>
<Footer>
{frontmatter!.date!}
{" ・ "}
{fields!.readingTime!.text!}
</Footer>
</Space>
</Metadata>
);
};
export const BlogArticleTeaserMetadataGraphQLFragment = graphql`
fragment BlogArticleTeaserMetadata on Mdx {
fields {
readingTime {
text
}
}
frontmatter {
author
authorImageUrl
date(formatString: "MMMM DD, YYYY")
title
}
}
`;
const Metadata = styled.div`
display: flex;
flex: 1 1 auto;
flex-direction: column;
justify-content: space-between;
margin: 28px 24px;
`;
const Author = styled.div.attrs({
className: "text-3",
})`
display: flex;
flex: 0 0 auto;
flex-direction: row;
align-items: center;
margin-bottom: 28px;
color: ${THEME_COLORS.textAlt};
`;
const AuthorImage = styled.img`
flex: 0 0 auto;
margin-right: 8px;
border-radius: 13px;
width: 26px;
`;
const Space = styled.div`
display: flex;
flex: 1 1 auto;
flex-direction: column;
justify-content: space-between;
`;
const Title = styled.h5`
margin-bottom: 28px;
`;
const Footer = styled.div.attrs({
className: "text-3",
})`
display: flex;
flex-direction: row;
align-items: center;
color: ${THEME_COLORS.textAlt};
`;