@mark1russell7/site-pages 0.2.5 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -418,14 +418,15 @@ interface KpiFile {
418
418
  project: string;
419
419
  at: string; // the ISO time of the data in UTC, never the time of the build
420
420
  commit: string; // the full commit of the build
421
- measures: Array<{ id: string; value: number; unit?: string }>;
421
+ measures: Array<{ id: string; value: number; unit?: string; at?: string }>;
422
422
  engines?: Array<{ name: string; version: string }>; // the Status page shows them
423
423
  }
424
424
  ```
425
425
 
426
426
  - Give `at` from the record of the data. The writer has no default for this field, because a build time hides old data.
427
+ - Give `at` on a measure when its data is from another time than the file. The Status page then shows a date for each measure.
427
428
  - Without `commit`, the plugin takes `GITHUB_SHA`, else the head of the repository.
428
- - A fault in the data stops the build, and the old site stays. A fault is a wrong form, a value that is not finite, a repeated id or a time after the check.
429
+ - A fault in the data stops the build, and the old site stays. A fault is a wrong form, a value that is not finite, a repeated id or a time after the check. The time rules apply to the file and to each measure.
429
430
  - A site with no Vite build calls `writeKpi(out, input)` from the root entry, before `site-pages build`.
430
431
  - `site-pages build` reads the file from the output folder. It adds the file to `data/status.json`, and the Status page shows the measures, the data date and the engines.
431
432
 
@@ -2138,14 +2138,19 @@ function openWork(data) {
2138
2138
  const doneList = done.length === 0 ? `<p class="sp-done sp-small"><span aria-hidden="true">✓</span> No item is done.</p>` : `<details class="sp-done sp-c-done" data-sp-done><summary><span aria-hidden="true">✓</span> ${doneText} <span data-sp-done-label>Show the done items</span></summary><section class="sp-group sp-c-done" data-sp-group data-class="done" aria-label="The done items">${itemTable(done, data, columns)}<p class="sp-callout" data-sp-done-empty hidden>No done item matches the filters.</p></section></details>`;
2139
2139
  return `<section class="sp-section" aria-labelledby="open-work" data-sp-board><h2 id="open-work">Open work</h2><p class="sp-small sp-muted">Each row of a table of ${link(roadmapUrl(data), `<code>${escapeHtml(file)}</code>`)} with an ID and a status that is not done. The build reads the file, so this list follows each commit.</p>` + meter(items) + (open.length > 0 ? filters : "") + list + doneList + "</section>";
2140
2140
  }
2141
- /** This function renders the measures of `kpi.json`: their values, the date of the data and the engines that made it. */
2141
+ /**
2142
+ * This function renders the measures of `kpi.json`: their values, the date of the data and the engines that made it.
2143
+ * A measure with its own date shows that date in a column, so that the line above the table stays true.
2144
+ */
2142
2145
  function measures(data) {
2143
2146
  const { kpi } = data;
2144
2147
  if (kpi === void 0) return "";
2145
- const rows = kpi.measures.map((measure) => `<tr><th scope="row">${escapeHtml(measure.id)}</th><td>${measure.value}${measure.unit === void 0 ? "" : ` ${escapeHtml(measure.unit)}`}</td></tr>`).join("");
2148
+ const ownDates = kpi.measures.some((measure) => measure.at !== void 0);
2149
+ const dateCell = (at) => ownDates ? `<td><time datetime="${escapeHtml(at)}">${escapeHtml(longDate(at))}</time></td>` : "";
2150
+ const rows = kpi.measures.map((measure) => `<tr><th scope="row">${escapeHtml(measure.id)}</th><td>${measure.value}${measure.unit === void 0 ? "" : ` ${escapeHtml(measure.unit)}`}</td>${dateCell(measure.at ?? kpi.at)}</tr>`).join("");
2146
2151
  const engines = kpi.engines ?? [];
2147
2152
  const commit = link(`https://github.com/${data.source.github}/commit/${kpi.commit}`, `<code>${kpi.commit.slice(0, 7)}</code>`);
2148
- return `<section class="sp-section" aria-labelledby="measures"><h2 id="measures">Measures</h2><p>The data of these numbers is from <time datetime="${escapeHtml(kpi.at)}" data-sp-data-date>${escapeHtml(longDate(kpi.at))}</time>. The build of ${commit} published them.</p>` + (engines.length > 0 ? `<p>The engines of the data: ${listText(engines.map((engine) => `<code>${escapeHtml(engine.name)}</code> ${escapeHtml(engine.version)}`))}.</p>` : "") + `<div class="sp-table-box" tabindex="0" role="region" aria-label="Measures"><table class="sp-table"><thead><tr><th scope="col">Measure</th><th scope="col">Value</th></tr></thead><tbody>${rows}</tbody></table></div></section>`;
2153
+ return `<section class="sp-section" aria-labelledby="measures"><h2 id="measures">Measures</h2><p>${ownDates ? "The data date of the file is" : "The data of these numbers is from"} <time datetime="${escapeHtml(kpi.at)}" data-sp-data-date>${escapeHtml(longDate(kpi.at))}</time>. The build of ${commit} published them.</p>` + (engines.length > 0 ? `<p>The engines of the data: ${listText(engines.map((engine) => `<code>${escapeHtml(engine.name)}</code> ${escapeHtml(engine.version)}`))}.</p>` : "") + `<div class="sp-table-box" tabindex="0" role="region" aria-label="Measures"><table class="sp-table"><thead><tr><th scope="col">Measure</th><th scope="col">Value</th>${ownDates ? "<th scope=\"col\">Data date</th>" : ""}</tr></thead><tbody>${rows}</tbody></table></div></section>`;
2149
2154
  }
2150
2155
  function when(date) {
2151
2156
  const text = escapeHtml(longDate(date));