diff --git a/README.md b/README.md index dabaad3..f294426 100644 --- a/README.md +++ b/README.md @@ -218,7 +218,7 @@ Clone this repository on own GitHub account and deploy to Vercel: - - -- +-
diff --git a/src/utils/getNormalizedPost.js b/src/utils/getNormalizedPost.js new file mode 100644 index 0000000..5a00914 --- /dev/null +++ b/src/utils/getNormalizedPost.js @@ -0,0 +1,27 @@ +import getReadingTime from "reading-time"; + +export const getNormalizedPost = async (post) => { + const { frontmatter, compiledContent, rawContent, file } = post; + const ID = file.split("/").pop().split(".").shift(); + + return { + id: ID, + + pubDate: frontmatter.pubDate, + draft: frontmatter.draft, + + canonical: frontmatter.canonical, + slug: frontmatter.slug || ID, + + title: frontmatter.title, + description: frontmatter.description, + body: compiledContent(), + image: frontmatter.image, + + excerpt: frontmatter.excerpt, + authors: frontmatter.authors, + category: frontmatter.category, + tags: frontmatter.tags, + readingTime: Math.ceil(getReadingTime(rawContent()).minutes), + }; +};