Skip to content

Commit

Permalink
(docs) Fixes for "Migrating from Gatsby" doc (#17858)
Browse files Browse the repository at this point in the history
Noticed there's an extra backslash in the example which causes an error. 

**EDIT:**

Also the promise needs to be resolved using `.toString()` before it can be returned as `content` in props.
  • Loading branch information
gregrickaby committed Oct 14, 2020
1 parent 7f79821 commit 5b1be2b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions docs/migrating/from-gatsby.md
Expand Up @@ -84,10 +84,10 @@ import { getPostBySlug, getAllPosts } from '../lib/blog'

export async function getStaticProps({ params }) {
const post = getPostBySlug(params.slug)
const content = await remark()
const markdown = await remark()
.use(html)
.process(post.content || '')
.toString()
const content = markdown.toString()

return {
props: {
Expand Down Expand Up @@ -128,7 +128,7 @@ import { join } from 'path'
const postsDirectory = join(process.cwd(), 'src', 'content', 'blog')

export function getPostBySlug(slug) {
const realSlug = slug.replace(/\\.md$/, '')
const realSlug = slug.replace(/\.md$/, '')
const fullPath = join(postsDirectory, `${realSlug}.md`)
const fileContents = fs.readFileSync(fullPath, 'utf8')
const { data, content } = matter(fileContents)
Expand Down

0 comments on commit 5b1be2b

Please sign in to comment.