1
1
import PropTypes from 'prop-types' ;
2
2
import matter from 'gray-matter' ;
3
3
import ReactMarkdown from 'react-markdown' ;
4
- import remarkGfm from 'remark-gfm'
4
+ import remarkGfm from 'remark-gfm' ;
5
5
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter' ;
6
6
import Layout from 'components/Layout' ;
7
7
import headerColor from 'helpers/post-header' ;
@@ -12,7 +12,7 @@ export default function BlogPost({
12
12
siteTitle,
13
13
frontmatter,
14
14
markdownBody,
15
- date,
15
+ date
16
16
} ) {
17
17
// eslint-disable-next-line react/jsx-no-useless-fragment
18
18
if ( ! frontmatter ) return < > </ > ;
@@ -42,23 +42,21 @@ export default function BlogPost({
42
42
< div className = 'container' >
43
43
< div className = { styles . post__intro } > { frontmatter . intro } </ div >
44
44
< ReactMarkdown
45
- includeElementIndex = { true }
46
45
remarkPlugins = { [ remarkGfm ] }
47
46
components = { {
48
- code ( { node, inline, className, children, ref } ) {
47
+ // eslint-disable-next-line react/no-unstable-nested-components
48
+ code ( { inline, className, children } ) {
49
49
const match = / l a n g u a g e - ( \w + ) / . exec ( className || '' ) ;
50
50
51
51
return ! inline && match ? (
52
- < SyntaxHighlighter
53
- language = { match [ 1 ] }
54
- >
52
+ < SyntaxHighlighter language = { match [ 1 ] } >
55
53
{ String ( children ) . replace ( / \n $ / , '' ) }
56
54
</ SyntaxHighlighter >
57
55
) : (
58
56
< code className = { className } > { children } </ code >
59
57
) ;
60
58
} ,
61
- img : ProgressiveImage ,
59
+ img : ProgressiveImage
62
60
} }
63
61
>
64
62
{ markdownBody }
@@ -74,7 +72,7 @@ BlogPost.propTypes = {
74
72
siteTitle : PropTypes . string ,
75
73
frontmatter : PropTypes . object ,
76
74
markdownBody : PropTypes . string ,
77
- date : PropTypes . array ,
75
+ date : PropTypes . array
78
76
} ;
79
77
80
78
export async function getStaticProps ( { ...ctx } ) {
@@ -89,15 +87,15 @@ export async function getStaticProps({ ...ctx }) {
89
87
siteTitle : config . title ,
90
88
frontmatter : data . data ,
91
89
markdownBody : data . content ,
92
- date,
93
- } ,
90
+ date
91
+ }
94
92
} ;
95
93
}
96
94
97
95
export async function getStaticPaths ( ) {
98
- const blogSlugs = ( ( context ) => {
96
+ const blogSlugs = ( context => {
99
97
const keys = context . keys ( ) ;
100
- const data = keys . map ( ( key ) => {
98
+ const data = keys . map ( key => {
101
99
const slug = key . replace ( / ^ .* [ \\ / ] / , '' ) . slice ( 0 , - 3 ) ;
102
100
103
101
return slug ;
@@ -106,10 +104,10 @@ export async function getStaticPaths() {
106
104
return data ;
107
105
} ) ( require . context ( '../../posts' , true , / \. \/ .* \. m d $ / ) ) ;
108
106
109
- const paths = blogSlugs . map ( ( slug ) => `/post/${ slug } ` ) ;
107
+ const paths = blogSlugs . map ( slug => `/post/${ slug } ` ) ;
110
108
111
109
return {
112
110
paths,
113
- fallback : false ,
111
+ fallback : false
114
112
} ;
115
113
}
0 commit comments