1010export const layout = "layouts/base.vto" ;
1111
1212const CELLS = 40 ;
13+ // Phones can't fit 40 tappable cells; below the `sm` breakpoint only the most
14+ // recent MOBILE_CELLS are shown (the older ones are hidden, not re-laid-out).
15+ const MOBILE_CELLS = 20 ;
1316const MONTHS = [
1417 "Jan" ,
1518 "Feb" ,
@@ -83,12 +86,20 @@ export default function (data: Lume.Data): string {
8386 const days : Day [ ] = [ ] ;
8487 let strip = "" ;
8588 let totalCommits = 0 ;
89+ let mobileCommits = 0 ;
8690 for ( let i = CELLS - 1 ; i >= 0 ; i -- ) {
8791 const d = new Date ( end ) ;
8892 d . setUTCDate ( d . getUTCDate ( ) - i ) ;
8993 const key = ymd ( d ) ;
9094 const p = postByDate . get ( key ) ;
91- totalCommits += Number ( p ?. commits ?? 0 ) ;
95+ const idx = days . length ;
96+ const commits = Number ( p ?. commits ?? 0 ) ;
97+ totalCommits += commits ;
98+ // The oldest cells are hidden below `sm`; only the most recent
99+ // MOBILE_CELLS show on phones, and the caption counts match.
100+ const onMobile = idx >= CELLS - MOBILE_CELLS ;
101+ if ( onMobile ) mobileCommits += commits ;
102+ const vis = onMobile ? "" : "hidden sm:block " ;
92103 const size = p ?. size as string | undefined ;
93104 const active = ! ! size && size !== "N" ;
94105 // Three states: active (S/M/L), quiet (a size:N post exists), and no data
@@ -103,13 +114,12 @@ export default function (data: Lume.Data): string {
103114 const ring = isLatest
104115 ? " relative z-10 ring-2 ring-accent ring-offset-1 ring-offset-white"
105116 : "" ;
106- const idx = days . length ;
107117 // Active cells link straight to that day's article; empty cells are inert.
108118 strip += active
109119 ? `<a href="${
110120 p ! . url
111- } " data-i="${ idx } " class="${ base } ${ color } cursor-pointer${ ring } " title="${ tip } "></a>`
112- : `<span data-i="${ idx } " class="${ base } ${ color } " title="${ tip } "></span>` ;
121+ } " data-i="${ idx } " class="${ vis } ${ base } ${ color } cursor-pointer${ ring } " title="${ tip } "></a>`
122+ : `<span data-i="${ idx } " class="${ vis } ${ base } ${ color } " title="${ tip } "></span>` ;
113123 days . push ( {
114124 human : human ( d ) ,
115125 latest : isLatest ,
@@ -133,7 +143,10 @@ export default function (data: Lume.Data): string {
133143 `</nav>` ;
134144
135145 const caption =
136- `<p class="mt-2 m-0 text-right text-xs font-semibold uppercase tracking-wider text-ink-soft">Last 40 days · ${ totalCommits } commits</p>` ;
146+ `<p class="mt-2 m-0 text-right text-xs font-semibold uppercase tracking-wider text-ink-soft">` +
147+ `<span class="sm:hidden">Last ${ MOBILE_CELLS } days · ${ mobileCommits } commits</span>` +
148+ `<span class="hidden sm:inline">Last ${ CELLS } days · ${ totalCommits } commits</span>` +
149+ `</p>` ;
137150
138151 // The summary block starts on the latest in-window day. When there is one
139152 // it is a link (kept in sync with the shown day by JS); otherwise a note.
0 commit comments