Skip to content

Commit d383fab

Browse files
fix: prettier config - tab is 2 spaces
1 parent d64b364 commit d383fab

File tree

5 files changed

+579
-578
lines changed

5 files changed

+579
-578
lines changed

.prettierrc

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
2-
"trailingComma": "es5",
3-
"semi": false,
4-
"singleQuote": true
2+
"trailingComma": "es5",
3+
"semi": false,
4+
"singleQuote": true,
5+
"tabWidth": 2
56
}

pages/blog/[slug].tsx

+17-17
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,25 @@ import Layout from '../../components/layout/Layout'
44
import Header from '../../components/layout/Header'
55

66
export default function BlogTemplate(props) {
7-
return (
8-
<Layout pathname='/'>
9-
<Header />
10-
<h1>{props.post.data.title}</h1>
11-
<ReactMarkdown source={props.post.content} />
12-
</Layout>
13-
)
7+
return (
8+
<Layout pathname="/">
9+
<Header />
10+
<h1>{props.post.data.title}</h1>
11+
<ReactMarkdown source={props.post.content} />
12+
</Layout>
13+
)
1414
}
1515

1616
BlogTemplate.getInitialProps = async function(ctx) {
17-
const { slug } = ctx.query
18-
const content = await import(`../../content/blog/${slug}.md`)
19-
const post = matter(content.default)
17+
const { slug } = ctx.query
18+
const content = await import(`../../content/blog/${slug}.md`)
19+
const post = matter(content.default)
2020

21-
return {
22-
// fileRelativePath: `src/posts/${slug}.md`,
23-
post: {
24-
data: { ...post.data, slug },
25-
content: post.content
26-
}
27-
}
21+
return {
22+
// fileRelativePath: `src/posts/${slug}.md`,
23+
post: {
24+
data: { ...post.data, slug },
25+
content: post.content,
26+
},
27+
}
2828
}

pages/blog/index.tsx

+41-41
Original file line numberDiff line numberDiff line change
@@ -6,52 +6,52 @@ import matter from 'gray-matter'
66
import ReactMarkdown from 'react-markdown'
77

88
const Index = props => {
9-
return (
10-
<Layout pathname='/'>
11-
<Header />
12-
{props.posts.map(post => (
13-
<div>
14-
<Link
15-
key={post.data.slug}
16-
href={{ pathname: `/blog/${post.data.slug}` }}
17-
>
18-
<h3>{post.data.title}</h3>
19-
</Link>
20-
<ReactMarkdown source={post.content} />
21-
<br />
22-
</div>
23-
))}
24-
</Layout>
25-
)
9+
return (
10+
<Layout pathname="/">
11+
<Header />
12+
{props.posts.map(post => (
13+
<div>
14+
<Link
15+
key={post.data.slug}
16+
href={{ pathname: `/blog/${post.data.slug}` }}
17+
>
18+
<h3>{post.data.title}</h3>
19+
</Link>
20+
<ReactMarkdown source={post.content} />
21+
<br />
22+
</div>
23+
))}
24+
</Layout>
25+
)
2626
}
2727

2828
Index.getInitialProps = async function(ctx) {
29-
const posts = (context => {
30-
const keys = context.keys()
31-
const values = keys.map(context)
32-
const data = keys.map((key: string, index: number) => {
33-
// Create slug from filename
34-
const slug = key
35-
.replace(/^.*[\\\/]/, '')
36-
.split('.')
37-
.slice(0, -1)
38-
.join('.')
39-
const value = values[index]
40-
// Parse yaml metadata & markdownbody in document
41-
const post = matter(value.default)
42-
console.log(JSON.stringify(post))
43-
return {
44-
data: { ...post.data, slug },
45-
content: post.content.substring(0, 300)
46-
}
47-
})
29+
const posts = (context => {
30+
const keys = context.keys()
31+
const values = keys.map(context)
32+
const data = keys.map((key: string, index: number) => {
33+
// Create slug from filename
34+
const slug = key
35+
.replace(/^.*[\\\/]/, '')
36+
.split('.')
37+
.slice(0, -1)
38+
.join('.')
39+
const value = values[index]
40+
// Parse yaml metadata & markdownbody in document
41+
const post = matter(value.default)
42+
console.log(JSON.stringify(post))
43+
return {
44+
data: { ...post.data, slug },
45+
content: post.content.substring(0, 300),
46+
}
47+
})
4848

49-
return data
50-
})((require as any).context('../../content/blog', true, /\.md$/))
49+
return data
50+
})((require as any).context('../../content/blog', true, /\.md$/))
5151

52-
return {
53-
posts
54-
}
52+
return {
53+
posts,
54+
}
5555
}
5656

5757
export default Index

0 commit comments

Comments
 (0)