Add utils folder

This commit is contained in:
prototypa
2022-08-17 22:43:13 -04:00
parent 478aa56b33
commit 399f44c67b
2 changed files with 42 additions and 0 deletions

View File

@ -0,0 +1,17 @@
import getReadingTime from "reading-time";
export const getNormalizedPost = async (post) => {
const { frontmatter, compiledContent, rawContent, file } = post;
return {
pubDate: frontmatter.pubDate,
title: frontmatter.title,
description: frontmatter.description,
excerpt: frontmatter.excerpt,
body: compiledContent(),
image: frontmatter.image,
authors: frontmatter.authors,
slug: file.split("/").pop().split(".").shift(),
readingTime: Math.ceil(getReadingTime(rawContent()).minutes),
};
};