use word count to get read time estimate
This commit is contained in:
parent
2a2d5df94a
commit
e10871b8ae
@ -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))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user