diff --git a/assets/resource-page.css b/assets/resource-page.css index fb6bf255..dcc2708a 100644 --- a/assets/resource-page.css +++ b/assets/resource-page.css @@ -104,6 +104,8 @@ aside { align-self: start; position: sticky; top: 5rem; } .row:last-child { border-bottom: 0; } .row dt { color: var(--text-muted); } .row dd { text-align: right; font-weight: 500; } +.row[hidden] { display: none; } +#viewsValue { font-family: var(--font-mono); font-variant-numeric: tabular-nums; } .aside-links { display: grid; gap: 0.5rem; margin-top: 1rem; font-size: 0.875rem; } .site-footer { border-top: 1px solid var(--border); padding: 2.5rem 0; color: var(--text-muted); font-size: 0.875rem; text-align: center; } diff --git a/assets/resource-page.js b/assets/resource-page.js index c7416204..0f51c0ea 100644 --- a/assets/resource-page.js +++ b/assets/resource-page.js @@ -52,6 +52,27 @@ }); } + // Views come from the published stats, so the page needs no rebuild when the counts change. The row + // stays hidden if the file cannot be read. Keep VIEWS_TIP in step with the catalog (index.html). + var VIEWS_TIP = "Catalog page views recorded by Microsoft Clarity since Jul 2026, plus views of the resource's GitHub folder from saved snapshots (Apr\u2013Jun and 14\u201327 Oct 2026). Some days were never captured, so this is a minimum."; + var viewsRow = document.getElementById('viewsRow'); + var viewsValue = document.getElementById('viewsValue'); + if (viewsRow && viewsValue && slug && script && script.src && window.fetch) { + fetch(new URL('../resource-stats.json', script.src).href, { cache: 'no-cache' }) + .then(function (response) { if (!response.ok) throw new Error('HTTP ' + response.status); return response.json(); }) + .then(function (data) { + if (!data || !data.resources || typeof data.resources !== 'object') return; + var entry = data.resources[slug]; + var views = entry ? Number(entry.views) : 0; + if (!isFinite(views) || views < 0) views = 0; + var short = views >= 10000 ? (views / 1000).toFixed(0) + 'k' : views >= 1000 ? (views / 1000).toFixed(1) + 'k' : String(views); + viewsValue.textContent = short; + viewsRow.title = views.toLocaleString('en-US') + (views === 1 ? ' view. ' : ' views. ') + VIEWS_TIP; + viewsRow.hidden = false; + }) + .catch(function () { /* leave the row hidden */ }); + } + // The download page saves the file by itself; its visible link covers blocked scripts. var autoDownload = document.querySelector('[data-autodownload]'); if (autoDownload) { diff --git a/r/add-engagegroupadmins/index.html b/r/add-engagegroupadmins/index.html index 67dc78b0..7701a4d2 100644 --- a/r/add-engagegroupadmins/index.html +++ b/r/add-engagegroupadmins/index.html @@ -79,7 +79,7 @@