Site URL: https://www.almendritasabia.com/blog/la-adiccion-es-una-enfermedad
Hello, I added a reading time to my blog posts, thanks to this article I saw online: https://www.maryphilip.com/the-blog/how-to-add-a-reading-time-to-your-squarespace-blog
I don't want to have to add a code block to each single post. So I followed the following instructions:
1. To add to all blogs, go to the Blog’s Page Settings, click Post Blog Item Code Injection and add the following:
Copy Code
<div class="reading-time"></div>
2. Go to Settings > Advanced > Code Injection and paste the following into the Header:
Copy Code
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(function () {
var txt = $("article")[0].textContent,
wordCount = txt.replace( /[^\w ]/g, "" ).split( /\s+/ ).length;
var readingTimeInMinutes = Math.floor(wordCount / 228) + 1;
var readingTimeAsString = readingTimeInMinutes + " min";
$('article .reading-time').html(readingTimeAsString);
});
</script>
3. Change the design to your liking. Go to Design, click Custom CSS, and paste the following:
Copy Code
.reading-time {
text-align: center;
font-size: 18px;
font-family: 'Playfair Display'
}
To add text before the time count, adapt the content with this CSS to your liking:
Copy Code
.reading-time:before {
content: 'Reading Time:';
margin-right: 3px;
}
(I changed a little of the CSS)
So it appears at the bottom.
And I was wondering if it's possible to move it under the blog title?
TThank you! 🙂