Skip to content

Commit

Permalink
fix: prettier config - tab is 2 spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
kendallstrautman committed Jan 29, 2020
1 parent d64b364 commit d383fab
Show file tree
Hide file tree
Showing 5 changed files with 579 additions and 578 deletions.
7 changes: 4 additions & 3 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"trailingComma": "es5",
"semi": false,
"singleQuote": true
"trailingComma": "es5",
"semi": false,
"singleQuote": true,
"tabWidth": 2
}
34 changes: 17 additions & 17 deletions pages/blog/[slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@ import Layout from '../../components/layout/Layout'
import Header from '../../components/layout/Header'

export default function BlogTemplate(props) {
return (
<Layout pathname='/'>
<Header />
<h1>{props.post.data.title}</h1>
<ReactMarkdown source={props.post.content} />
</Layout>
)
return (
<Layout pathname="/">
<Header />
<h1>{props.post.data.title}</h1>
<ReactMarkdown source={props.post.content} />
</Layout>
)
}

BlogTemplate.getInitialProps = async function(ctx) {
const { slug } = ctx.query
const content = await import(`../../content/blog/${slug}.md`)
const post = matter(content.default)
const { slug } = ctx.query
const content = await import(`../../content/blog/${slug}.md`)
const post = matter(content.default)

return {
// fileRelativePath: `src/posts/${slug}.md`,
post: {
data: { ...post.data, slug },
content: post.content
}
}
return {
// fileRelativePath: `src/posts/${slug}.md`,
post: {
data: { ...post.data, slug },
content: post.content,
},
}
}
82 changes: 41 additions & 41 deletions pages/blog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,52 +6,52 @@ import matter from 'gray-matter'
import ReactMarkdown from 'react-markdown'

const Index = props => {
return (
<Layout pathname='/'>
<Header />
{props.posts.map(post => (
<div>
<Link
key={post.data.slug}
href={{ pathname: `/blog/${post.data.slug}` }}
>
<h3>{post.data.title}</h3>
</Link>
<ReactMarkdown source={post.content} />
<br />
</div>
))}
</Layout>
)
return (
<Layout pathname="/">
<Header />
{props.posts.map(post => (
<div>
<Link
key={post.data.slug}
href={{ pathname: `/blog/${post.data.slug}` }}
>
<h3>{post.data.title}</h3>
</Link>
<ReactMarkdown source={post.content} />
<br />
</div>
))}
</Layout>
)
}

Index.getInitialProps = async function(ctx) {
const posts = (context => {
const keys = context.keys()
const values = keys.map(context)
const data = keys.map((key: string, index: number) => {
// Create slug from filename
const slug = key
.replace(/^.*[\\\/]/, '')
.split('.')
.slice(0, -1)
.join('.')
const value = values[index]
// Parse yaml metadata & markdownbody in document
const post = matter(value.default)
console.log(JSON.stringify(post))
return {
data: { ...post.data, slug },
content: post.content.substring(0, 300)
}
})
const posts = (context => {
const keys = context.keys()
const values = keys.map(context)
const data = keys.map((key: string, index: number) => {
// Create slug from filename
const slug = key
.replace(/^.*[\\\/]/, '')
.split('.')
.slice(0, -1)
.join('.')
const value = values[index]
// Parse yaml metadata & markdownbody in document
const post = matter(value.default)
console.log(JSON.stringify(post))
return {
data: { ...post.data, slug },
content: post.content.substring(0, 300),
}
})

return data
})((require as any).context('../../content/blog', true, /\.md$/))
return data
})((require as any).context('../../content/blog', true, /\.md$/))

return {
posts
}
return {
posts,
}
}

export default Index
Loading

0 comments on commit d383fab

Please sign in to comment.