forked from codesandbox/codesandbox-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpost.js
More file actions
88 lines (78 loc) · 1.82 KB
/
post.js
File metadata and controls
88 lines (78 loc) · 1.82 KB
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
import { format } from 'date-fns';
import { graphql } from 'gatsby';
import React from 'react';
import Layout from '../components/layout';
import PageContainer from '../components/PageContainer';
import {
Author,
AuthorImage,
Container,
PostDate,
Title,
} from '../components/PostElements';
import TitleAndMetaTags from '../components/TitleAndMetaTags';
import {
AuthorContainer,
Image,
MetaData,
PostContainer,
} from './_post.elements';
export default ({
data: {
blogPost: {
fields: { authors, date, description, photo, title },
frontmatter: {
banner: { publicURL: banner },
},
html,
},
},
}) => (
<Layout>
<Container style={{ overflowX: 'auto' }}>
<TitleAndMetaTags
description={description}
image={banner}
title={`${title} - CodeSandbox Blog`}
/>
<PageContainer width={800}>
<Title>{title}</Title>
<MetaData>
<div style={{ flex: 1 }}>
{authors.map(author => (
<AuthorContainer key={author}>
{authors.length === 1 && (
<AuthorImage alt={author} src={photo} />
)}
<Author>{author}</Author>
</AuthorContainer>
))}
</div>
<PostDate>{format(date, 'MMM DD, YYYY')}</PostDate>
</MetaData>
<Image alt={title} src={banner} />
<PostContainer dangerouslySetInnerHTML={{ __html: html }} />
</PageContainer>
</Container>
</Layout>
);
export const pageQuery = graphql`
query Post($id: String) {
blogPost: markdownRemark(id: { eq: $id }) {
fields {
authors
date
description
photo
slug
title
}
frontmatter {
banner {
publicURL
}
}
html
}
}
`;