File tree Expand file tree Collapse file tree 4 files changed +98
-6
lines changed Expand file tree Collapse file tree 4 files changed +98
-6
lines changed Original file line number Diff line number Diff line change @@ -6,8 +6,8 @@ const PostTemplateBlock = styled(PageTemplate)``;
6
6
7
7
interface PostTemplateProps { }
8
8
9
- const PostTemplate : React . SFC < PostTemplateProps > = props => {
10
- return < PostTemplateBlock > 포스트임 </ PostTemplateBlock > ;
9
+ const PostTemplate : React . SFC < PostTemplateProps > = ( { children } ) => {
10
+ return < PostTemplateBlock > { children } </ PostTemplateBlock > ;
11
11
} ;
12
12
13
13
export default PostTemplate ;
Original file line number Diff line number Diff line change
1
+ import * as React from 'react' ;
2
+ import styled from 'styled-components' ;
3
+ import { Query , QueryResult } from 'react-apollo' ;
4
+ import { READ_POST , SinglePost } from '../../lib/graphql/post' ;
5
+
6
+ export interface PostViewerProps {
7
+ username : string ;
8
+ urlSlug : string ;
9
+ }
10
+
11
+ const PostViewer : React . FC < PostViewerProps > = ( { username, urlSlug } ) => {
12
+ return (
13
+ < Query
14
+ query = { READ_POST }
15
+ variables = { {
16
+ username,
17
+ url_slug : urlSlug ,
18
+ } }
19
+ >
20
+ { ( result : QueryResult < { post : SinglePost } > ) => {
21
+ console . log ( result ) ;
22
+ return null ;
23
+ } }
24
+ </ Query >
25
+ ) ;
26
+ } ;
27
+
28
+ export default PostViewer ;
Original file line number Diff line number Diff line change @@ -37,8 +37,33 @@ export type PartialPost = {
37
37
comments_count : number ;
38
38
} ;
39
39
40
+ // Generated by https://quicktype.io
41
+
42
+ export interface SinglePost {
43
+ id : string ;
44
+ title : string ;
45
+ released_at : string ;
46
+ updated_at : string ;
47
+ tags : string [ ] ;
48
+ body : string ;
49
+ is_markdown : boolean ;
50
+ is_private : boolean ;
51
+ is_temp : boolean ;
52
+ user : {
53
+ username : string ;
54
+ profile : {
55
+ display_name : string ;
56
+ thumbnail : string ;
57
+ short_bio : string ;
58
+ } ;
59
+ velog_config : {
60
+ title : string ;
61
+ } ;
62
+ } ;
63
+ }
64
+
40
65
export const GET_POST_LIST = gql `
41
- query Post ($cursor: ID) {
66
+ query Posts ($cursor: ID) {
42
67
posts(cursor: $cursor) {
43
68
id
44
69
title
@@ -60,6 +85,33 @@ export const GET_POST_LIST = gql`
60
85
}
61
86
` ;
62
87
88
+ export const READ_POST = gql `
89
+ query ReadPost($username: String, $url_slug: String) {
90
+ post(username: $username, url_slug: $url_slug) {
91
+ id
92
+ title
93
+ released_at
94
+ updated_at
95
+ tags
96
+ body
97
+ is_markdown
98
+ is_private
99
+ is_temp
100
+ user {
101
+ username
102
+ profile {
103
+ display_name
104
+ thumbnail
105
+ short_bio
106
+ }
107
+ velog_config {
108
+ title
109
+ }
110
+ }
111
+ }
112
+ }
113
+ ` ;
114
+
63
115
export const WRITE_POST = gql `
64
116
mutation WritePost(
65
117
$title: String
Original file line number Diff line number Diff line change 1
1
import * as React from 'react' ;
2
+ import { RouteComponentProps } from 'react-router-dom' ;
2
3
import PostTemplate from '../components/post/PostTemplate' ;
4
+ import PostViewer from '../containers/post/PostViewer' ;
3
5
4
- interface PostPageProps { }
6
+ interface PostPageProps
7
+ extends RouteComponentProps < {
8
+ username : string ;
9
+ urlSlug : string ;
10
+ } > { }
5
11
6
- const PostPage : React . SFC < PostPageProps > = ( ) => {
7
- return < PostTemplate /> ;
12
+ const PostPage : React . SFC < PostPageProps > = ( { match } ) => {
13
+ const { username, urlSlug } = match . params ;
14
+
15
+ return (
16
+ < PostTemplate >
17
+ < PostViewer username = { username } urlSlug = { urlSlug } />
18
+ </ PostTemplate >
19
+ ) ;
8
20
} ;
9
21
10
22
export default PostPage ;
You can’t perform that action at this time.
0 commit comments