use word count to get read time estimate

This commit is contained in:
eggy 2021-04-14 15:23:11 -04:00
parent 2a2d5df94a
commit e10871b8ae

View File

@ -23,8 +23,8 @@ module.exports = function(eleventyConfig) {
// To create a filter to determine duration of post // To create a filter to determine duration of post
eleventyConfig.addFilter('readTime', (value) => { eleventyConfig.addFilter('readTime', (value) => {
const content = value const content = value
const textOnly = content.replace(/(<([^>]+)>)/gi, '') const textOnly = content.split(" ")//content.replace(/(<([^>]+)>)/gi, '')
const readingSpeedPerMin = 450 const readingSpeedPerMin = 300
return Math.max(1, Math.floor(textOnly.length / readingSpeedPerMin)) return Math.max(1, Math.floor(textOnly.length / readingSpeedPerMin))
}) })