Vorlage:ReadingTime

Aus Geoportal
Version vom 13. Oktober 2023, 05:43 Uhr von Deepak (Diskussion | Beiträge) (Die Seite wurde neu angelegt: „<div id="reading-time">Reading time: Calculating...</div> <script> function calculateReadingTime() { const wordsPerMinute = 200; // Adjust this value based…“)
(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)
Reading time: Calculating...

<script> function calculateReadingTime() {

   const wordsPerMinute = 200; // Adjust this value based on your content.
   const text = document.body.innerText;
   const words = text.split(/\s+/).length;
   const readingTime = Math.ceil(words / wordsPerMinute);
   document.getElementById('reading-time').textContent = `Reading time: ${readingTime} minutes`;

} calculateReadingTime(); </script>