File tree Expand file tree Collapse file tree 2 files changed +25
-37
lines changed Expand file tree Collapse file tree 2 files changed +25
-37
lines changed Original file line number Diff line number Diff line change 1
- import React from "react"
1
+ import * as React from "react"
2
+ import { graphql , Link } from "gatsby"
2
3
import Marked from "../Marked"
3
- import { Link } from "gatsby"
4
+
5
+ export const fragments = graphql `
6
+ fragment BlogPost_post on BlogPost {
7
+ title
8
+ excerpt
9
+ rawContent
10
+ date
11
+ authors
12
+ tags
13
+ }
14
+ ` ;
4
15
5
16
interface Props {
6
- title : string
7
- date : string
8
- permalink : string
9
- byline : string
10
- guestBio : string
11
- rawMarkdownBody : string
12
- isPermalink : boolean
13
- pageContext : any
14
- excerpt ?: string
15
- showExcerpt ?: true
16
- tags : Array < string >
17
+ post : GatsbyTypes . BlogPost_postFragment ,
18
+ showExcerpt : boolean ,
17
19
}
18
20
19
- const BlogPost = ( {
20
- title,
21
- date,
22
- permalink,
23
- byline,
24
- guestBio,
25
- rawMarkdownBody,
26
- isPermalink,
27
- pageContext,
28
- excerpt,
21
+ const BlogPost : React . FC < Props > = ( {
22
+ post,
29
23
showExcerpt,
30
- tags,
31
- } : Props ) => (
24
+ } ) => (
32
25
< div className = "inner-content" >
33
- < h1 > { isPermalink ? title : < a href = { permalink } > { title } </ a > } </ h1 >
26
+ < h1 > { post . title } </ h1 >
34
27
< p >
35
- { new Date ( date ) . toLocaleDateString ( ) } by { byline }
28
+ { new Date ( post . date ) . toLocaleDateString ( ) } by { post . authors . join ( ', ' ) }
36
29
</ p >
37
30
< div className = "tag-wrapper" >
38
- { tags . map ( tag => (
39
- < span className = "tag" >
31
+ { post . tags . map ( tag => (
32
+ < span key = { tag } className = "tag" >
40
33
< Link to = { `/tags/${ tag } ` } > { tag } </ Link >
41
34
</ span >
42
35
) ) }
43
36
</ div >
44
37
45
- { guestBio ? null : < hr /> }
46
- { guestBio && (
47
- < p className = "guestBio" > { `This guest article contributed by ${ byline } , ${ guestBio } .` } </ p >
48
- ) }
49
-
50
38
{ showExcerpt ? (
51
- < p > { excerpt } </ p >
39
+ < p > { post . excerpt } </ p >
52
40
) : (
53
- < Marked pageContext = { pageContext } > { rawMarkdownBody } </ Marked >
41
+ < Marked > { post . rawContent } </ Marked >
54
42
) }
55
43
</ div >
56
44
)
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ import MiniGraphiQL from "./MiniGraphiQL"
14
14
import { StarWarsSchema } from "./swapiSchema"
15
15
import { UsersSchema } from './usersSchema' ;
16
16
17
- export default function Marked ( props : { children : React . ReactElement } ) {
17
+ export default function Marked ( props : { children : string } ) {
18
18
return < div > { props . children && marked ( props . children , props ) } </ div >
19
19
}
20
20
You can’t perform that action at this time.
0 commit comments