@mccaskie-labs/workbench-site 0.15.0 → 0.15.2
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/CHANGELOG.md +14 -0
- package/dist/builder.js +21 -6
- package/dist/styles.js +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @mccaskie-labs/workbench-site
|
|
2
2
|
|
|
3
|
+
## 0.15.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Two pages on the same menu number (header, footer, admin menu or Admin home's counts) keep one order, by address, whatever order they were added in.
|
|
8
|
+
|
|
9
|
+
## 0.15.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- A page with a tool's own section names the words that section draws, in a comment beside the call, so the project's strings check finds them in use.
|
|
14
|
+
- A "needs you" count's word (such as Bookings' "Booking requests to answer") goes into the strings catalogue only with the admins' dashboard, where it is said. A site that adds Admin home later gets the words of the counts it already has.
|
|
15
|
+
- A tool's own section that ends the page has the same space under it as the site's sections, so it doesn't touch the footer.
|
|
16
|
+
|
|
3
17
|
## 0.15.0
|
|
4
18
|
|
|
5
19
|
### Minor Changes
|
package/dist/builder.js
CHANGED
|
@@ -156,12 +156,21 @@ export function buildSite(o) {
|
|
|
156
156
|
return fail();
|
|
157
157
|
}
|
|
158
158
|
const words = { ...strings };
|
|
159
|
+
// A "needs you" count's word is said only on the admins' dashboard (src/pages/needs.ts), so it comes with the dashboard.
|
|
160
|
+
const countWord = (r) => r.needsYou?.label;
|
|
159
161
|
for (const id of added) {
|
|
160
162
|
const r = byId.get(id);
|
|
161
163
|
for (const k of recipeKeys(r))
|
|
162
|
-
if (!(k in words))
|
|
164
|
+
if (!(k in words) && (dashboard || k !== countWord(r)))
|
|
163
165
|
words[k] = r.words[k];
|
|
164
166
|
}
|
|
167
|
+
if (dashboard)
|
|
168
|
+
for (const p of pages) {
|
|
169
|
+
const r = byId.get(p.recipe);
|
|
170
|
+
const k = r && countWord(r);
|
|
171
|
+
if (r && k && p.path !== null && !(k in words))
|
|
172
|
+
words[k] = r.words[k];
|
|
173
|
+
}
|
|
165
174
|
writes[stringsPath] = `${JSON.stringify(words, null, 2)}\n`;
|
|
166
175
|
// The dependency the page files import.
|
|
167
176
|
let pkg;
|
|
@@ -306,7 +315,7 @@ function pageFile(r, version, base, pathOf) {
|
|
|
306
315
|
if (s.kind !== "tool")
|
|
307
316
|
return [s, sectionCode(s, pathOf, r.path)];
|
|
308
317
|
n += 1;
|
|
309
|
-
tools.push({ name: `tool${n}`, from: s.from, fn: s.fn });
|
|
318
|
+
tools.push({ name: `tool${n}`, from: s.from, fn: s.fn, words: s.words });
|
|
310
319
|
return [s, `tool${n}(w)`];
|
|
311
320
|
})
|
|
312
321
|
.filter((x) => x[1] !== null);
|
|
@@ -325,7 +334,11 @@ function pageFile(r, version, base, pathOf) {
|
|
|
325
334
|
...(list ? [" const enquiries = await listEnquiries(env, ctx);"] : []),
|
|
326
335
|
...(needs ? [" // Each tool's count, read at once (src/pages/needs.ts).", " const needs = await readNeeds(env, ctx);"] : []),
|
|
327
336
|
...(guide ? [" // ?view=light, dark or admin: the switch at the top of the guide.", " const view = guideView(request.url);"] : []),
|
|
328
|
-
...tools.
|
|
337
|
+
...tools.flatMap((t) => [
|
|
338
|
+
// The words the tool draws itself, named here so the strings check finds them in use.
|
|
339
|
+
...(t.words.length ? [` // ${t.fn} draws its own words: ${t.words.map((k) => JSON.stringify(k)).join(", ")}.`] : []),
|
|
340
|
+
` const ${t.name} = await ${t.fn}(request, env, ctx);`,
|
|
341
|
+
]),
|
|
329
342
|
...(owned ? [" // The words the owner changed on the Settings page (\"Your pages' words\").", " const words = await ownerWords(env);"] : []),
|
|
330
343
|
];
|
|
331
344
|
const block = pre.length > 0;
|
|
@@ -466,13 +479,15 @@ function indexFile(pages, byId) {
|
|
|
466
479
|
].join("\n");
|
|
467
480
|
}
|
|
468
481
|
/** src/pages/needs.ts: the admin dashboard's counts, one per page on the site that has one, in the admin menu's order. */
|
|
482
|
+
/** Two menu places on the same number keep one order: by address. */
|
|
483
|
+
const byText = (a, b) => (a < b ? -1 : a > b ? 1 : 0);
|
|
469
484
|
function needsFile(pages, byId) {
|
|
470
485
|
const counts = pages
|
|
471
486
|
.flatMap((p) => {
|
|
472
487
|
const r = byId.get(p.recipe);
|
|
473
488
|
return r?.needsYou && p.path !== null ? [{ order: r.menu?.admin ?? 1000, label: r.needsYou.label, href: p.path, file: r.needsYou.file, fn: r.needsYou.fn }] : [];
|
|
474
489
|
})
|
|
475
|
-
.sort((a, b) => a.order - b.order);
|
|
490
|
+
.sort((a, b) => a.order - b.order || byText(a.href, b.href));
|
|
476
491
|
const imports = [...new Map(counts.map((c) => [`${c.fn}|${c.file}`, c])).values()].map((c) => `import { ${c.fn} } from "./${c.file.replace(/^src\/pages\//, "")}";`);
|
|
477
492
|
return [
|
|
478
493
|
`// Generated by ${PACKAGE} from workbench/site.json and its recipes: \`npx workbench-site add <page>\``,
|
|
@@ -545,7 +560,7 @@ function navFile(pages, byId) {
|
|
|
545
560
|
const entries = (place) => pages
|
|
546
561
|
.map((p) => ({ p, menu: byId.get(p.recipe)?.menu }))
|
|
547
562
|
.filter((x) => x.p.path !== null && x.menu?.[place] !== undefined)
|
|
548
|
-
.sort((a, b) => a.menu[place] - b.menu[place])
|
|
563
|
+
.sort((a, b) => a.menu[place] - b.menu[place] || byText(a.p.path, b.p.path))
|
|
549
564
|
.map(({ p, menu }) => ` [${JSON.stringify(menu.label)}, ${JSON.stringify(p.path)}],`);
|
|
550
565
|
const admin = [
|
|
551
566
|
...pages.flatMap((p) => {
|
|
@@ -554,7 +569,7 @@ function navFile(pages, byId) {
|
|
|
554
569
|
}),
|
|
555
570
|
...pages.flatMap((p) => (byId.get(p.recipe)?.links ?? []).map((l) => ({ order: l.admin, label: l.label, href: l.href, about: l.about }))),
|
|
556
571
|
]
|
|
557
|
-
.sort((a, b) => a.order - b.order)
|
|
572
|
+
.sort((a, b) => a.order - b.order || byText(a.href, b.href))
|
|
558
573
|
.map((l) => ` [${JSON.stringify(l.label)}, ${JSON.stringify(l.href)}, ${JSON.stringify(l.about)}],`);
|
|
559
574
|
const list = (lines) => (lines.length ? `[\n${lines.join("\n")}\n]` : "[]");
|
|
560
575
|
return [
|
package/dist/styles.js
CHANGED
|
@@ -74,6 +74,7 @@ export const SITE_STYLES = {
|
|
|
74
74
|
states: [
|
|
75
75
|
{ selector: "[data-frame=\"landing\"]", about: "Landing frame: full width", css: `max-width:${v("width")}` },
|
|
76
76
|
{ selector: "[data-frame=\"column\"]", about: "Column frame: one reading-width column", css: `max-width:${v("reading")}` },
|
|
77
|
+
{ selector: " > :last-child:not(.wb-site-section):not(.wb-site-columns)", about: "A tool's own section last on the page: the same space under it as under the site's sections", css: `margin-bottom:${v("section-space")}` },
|
|
77
78
|
{ selector: "[data-frame=\"two-columns\"]", about: "Two-columns frame: the first section across the top, the rest beside each other", css: `max-width:${v("width")}` },
|
|
78
79
|
],
|
|
79
80
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mccaskie-labs/workbench-site",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.2",
|
|
4
4
|
"description": "A Workbench project's standard pages: page recipes, the builder that turns them into thin page files calling Workbench's tools, and the page frames and sections they are drawn with (wb-site-*, restylable, on the project's theme tokens).",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|