Skip to content
This repository has been archived by the owner on Feb 27, 2022. It is now read-only.

feat: add 'reading-time' and word count #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bketelsen
Copy link

Adds 'reading-time', propagating reading_time and word_count in frontMatter.
Adds test for reading_time and word_count.

@bketelsen
Copy link
Author

@arshad are there any changes you want me to make to this PR?

@shadcn
Copy link
Owner

shadcn commented Mar 25, 2021

Sorry. I forgot to review this. I added a few comments on the issue: #3 (comment)

@@ -181,6 +182,11 @@ export async function getFileData(file: MdxFile): Promise<MdxFileData> {

const { content, data: frontMatter } = matter(raw)

const word_count = content.split(/\s+/gu).length
const reading_time = readingTime(content)
frontMatter.reading_time = reading_time
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants