Statamic Article Reading Time


Replicating my reading time indicator on Statamic proved to be incredibly easy. There’s actually an add-on that’s supposed to do the same thing, but the way I did it is much simpler and also works on the home-page. The add-on is probably the ideal way to do this, but hey, these aren’t called “hacks” for nothing.

Just put this code in your template files somewhere between the entries:listing tags.

<script language="javascript" type="text/javascript">
var readingtime = 1 / 250;
document.write(Math.round(readingtime + 1) + ' min read');
</script>

Change the 250 if you think your readers are capable of more or less than that number of words per minute. Reading time is incremented by one minute, always, because you don’t want really short posts clocking in at no time to read at all.

Say something clever

blog comments powered by Disqus