Full document, spreadsheet, slideshow, and diagram tooling
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request 'feat(docs): reading time estimate in footer' (#102) from feat/reading-time into main

scott 5feda519 2f6acaad

+4
+1
src/docs/index.html
··· 395 395 <!-- Word/character count footer --> 396 396 <div class="docs-footer" id="docs-footer"> 397 397 <span id="word-count">0 words</span> 398 + <span id="reading-time"></span> 398 399 <span id="char-count">0 characters</span> 399 400 <span id="char-count-no-spaces">0 without spaces</span> 400 401 </div>
+3
src/docs/main.ts
··· 1147 1147 1148 1148 // --- Word and character count (#16) --- 1149 1149 const wordCountEl = $('word-count'); 1150 + const readingTimeEl = $('reading-time'); 1150 1151 const charCountEl = $('char-count'); 1151 1152 const charCountNoSpacesEl = $('char-count-no-spaces'); 1152 1153 ··· 1156 1157 const chars = text.length; 1157 1158 const charsNoSpace = text.replace(/\s/g, '').length; 1158 1159 wordCountEl.textContent = `${words.toLocaleString()} words`; 1160 + const minutes = Math.max(1, Math.ceil(words / 250)); 1161 + readingTimeEl.textContent = words > 0 ? `${minutes} min read` : ''; 1159 1162 charCountEl.textContent = `${chars.toLocaleString()} characters`; 1160 1163 charCountNoSpacesEl.textContent = `${charsNoSpace.toLocaleString()} without spaces`; 1161 1164 }