Skip to content

Instantly share code, notes, and snippets.

@andreaselia
Created January 14, 2021 14:05
vue / nuxt reading time for blog posts/articles
<template>
<div>{{ readingTime }} min read</div>
</template>
<script>
export default {
props: ['content'],
computed: {
readingTime () {
let minutes = 0
const contentAsString = JSON.stringify(this.content)
const words = contentAsString.split(' ').length
const wordsPerMinute = 200
minutes = Math.ceil(words / wordsPerMinute)
return minutes
}
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment