From 5b1be2bb980c4cad7e543a9f150c1a1c50a6c0f3 Mon Sep 17 00:00:00 2001 From: Greg Rickaby Date: Tue, 13 Oct 2020 22:01:38 -0500 Subject: [PATCH] (docs) Fixes for "Migrating from Gatsby" doc (#17858) 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. --- docs/migrating/from-gatsby.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/migrating/from-gatsby.md b/docs/migrating/from-gatsby.md index 2550ffc47f..79d59c6b1c 100644 --- a/docs/migrating/from-gatsby.md +++ b/docs/migrating/from-gatsby.md @@ -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: { @@ -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) -- GitLab