maverick-wave-astro 1.42.0 → 1.44.0

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.
@@ -119,8 +119,8 @@ const {
119
119
  ? 'Gerade gibt es nichts zu teilen.'
120
120
  : 'Nothing to share right now.',
121
121
  previewEmpty = german
122
- ? 'Hier entsteht gerade keine Story: Vergangenes zeigt die Vorschau nicht. Sobald ein kommender Eintrag veröffentlicht ist, siehst du hier seine Story.'
123
- : 'No story here right now: the preview leaves out what is over. Once an upcoming entry is published, its story shows here.',
122
+ ? 'Hier entsteht gerade keine Story: Vergangenes zeigt die Vorschau nicht. Sobald du einen kommenden Eintrag speicherst, siehst du hier seine Story.'
123
+ : 'No story here right now: the preview leaves out what is over. Once you save an upcoming entry, its story shows here.',
124
124
  soldOut = german ? 'Ausgebucht' : 'Sold out',
125
125
  free = german ? 'kostenlos' : 'free',
126
126
  currency = 'Euro',
@@ -181,9 +181,9 @@ const seriesStoryList = series.flatMap(one =>
181
181
 
182
182
  // What the browser needs to draw a series, and to redraw it from a preview.
183
183
  const seriesData = Object.fromEntries(
184
- series.map(({ name, config, items, fields }) => [
184
+ series.map(({ name, config, items, fields, standIns }) => [
185
185
  name,
186
- { config, items, fields },
186
+ { config, items, fields, standIns },
187
187
  ])
188
188
  );
189
189
 
@@ -420,6 +420,7 @@ const look: LookOptions = {
420
420
  type StoryPromoConfig,
421
421
  type StorySeries,
422
422
  type StorySeriesConfig,
423
+ withStandIns,
423
424
  } from '../dist/story/cards.js';
424
425
  import {
425
426
  blockPieces,
@@ -465,7 +466,7 @@ const look: LookOptions = {
465
466
  atob(value.replace(/-/g, '+').replace(/_/g, '/')),
466
467
  char => char.charCodeAt(0)
467
468
  );
468
- const { section, content, look } = JSON.parse(
469
+ const { section, content, look, items } = JSON.parse(
469
470
  new TextDecoder().decode(bytes)
470
471
  );
471
472
  return typeof section === 'string' &&
@@ -477,6 +478,11 @@ const look: LookOptions = {
477
478
  // With a story tab the designs as saved, published or not.
478
479
  look:
479
480
  look && typeof look === 'object' ? (look as StoriesConfig) : null,
481
+ // With a story tab the entries of its section as saved - the
482
+ // page itself only knows what was published.
483
+ items: Array.isArray(items)
484
+ ? (items as Readonly<Record<string, unknown>>[])
485
+ : null,
480
486
  }
481
487
  : null;
482
488
  } catch {
@@ -556,7 +562,12 @@ const look: LookOptions = {
556
562
  // running promotion.
557
563
  const showPreview = (
558
564
  container: HTMLElement,
559
- { section, content, look }: NonNullable<ReturnType<typeof readPreview>>
565
+ {
566
+ section,
567
+ content,
568
+ look,
569
+ items,
570
+ }: NonNullable<ReturnType<typeof readPreview>>
560
571
  ) => {
561
572
  container.classList.add('mwa-story-cards-preview');
562
573
  if (look) designs = designsOf(look);
@@ -603,6 +614,12 @@ const look: LookOptions = {
603
614
  } else if (offers) {
604
615
  empty?.before(offers);
605
616
  } else if (seriesData[section]) {
617
+ if (items) {
618
+ const { standIns = {} } = seriesData[section];
619
+ seriesData[section].items = items.map(item =>
620
+ withStandIns(item, standIns)
621
+ );
622
+ }
606
623
  const series = { name: section, ...seriesData[section] };
607
624
  const site = container.dataset.site ?? '';
608
625
  const locale = container.dataset.locale ?? 'de-DE';
@@ -1319,10 +1336,52 @@ const look: LookOptions = {
1319
1336
  }
1320
1337
  };
1321
1338
 
1339
+ // The werkbank flips through the stories with buttons beside the frame,
1340
+ // so nobody has to aim for the narrow frame to scroll it.
1341
+ const sheets = () => [
1342
+ ...root.querySelectorAll<HTMLElement>('.mwa-story-card'),
1343
+ ];
1344
+ const nearest = () => {
1345
+ const distances = sheets().map(sheet => {
1346
+ const box = sheet.getBoundingClientRect();
1347
+ return Math.abs(box.top + box.height / 2 - innerHeight / 2);
1348
+ });
1349
+ return distances.indexOf(Math.min(...distances));
1350
+ };
1351
+ let shown = 0;
1352
+ const tell = () =>
1353
+ parent.postMessage(
1354
+ { type: 'mw-story-blatt', nummer: shown, anzahl: sheets().length },
1355
+ '*'
1356
+ );
1357
+ let settling: ReturnType<typeof setTimeout> | undefined;
1358
+ addEventListener(
1359
+ 'scroll',
1360
+ () => {
1361
+ clearTimeout(settling);
1362
+ settling = setTimeout(() => {
1363
+ const now = Math.max(0, nearest());
1364
+ if (now === shown) return;
1365
+ shown = now;
1366
+ tell();
1367
+ }, 120);
1368
+ },
1369
+ { passive: true }
1370
+ );
1371
+
1322
1372
  addEventListener('message', event => {
1323
- if (event.source !== parent || event.data?.type !== 'mw-story-feld') {
1373
+ if (event.source !== parent) return;
1374
+ if (
1375
+ event.data?.type === 'mw-story-blatt' &&
1376
+ Number.isInteger(event.data.nummer)
1377
+ ) {
1378
+ const all = sheets();
1379
+ all[
1380
+ Math.max(0, Math.min(event.data.nummer, all.length - 1))
1381
+ ]?.scrollIntoView({ block: 'center', behavior: 'smooth' });
1324
1382
  return;
1325
1383
  }
1384
+ if (event.data?.type !== 'mw-story-feld') return;
1326
1385
  wanted = {
1327
1386
  path: typeof event.data.pfad === 'string' ? event.data.pfad : null,
1328
1387
  all: event.data.beschriften === true,
@@ -1339,6 +1398,7 @@ const look: LookOptions = {
1339
1398
  });
1340
1399
  // The frame may have sent before this script was ready - it answers this.
1341
1400
  parent.postMessage({ type: 'mw-story-bereit' }, '*');
1401
+ tell();
1342
1402
  }
1343
1403
  }
1344
1404
  </script>
package/dist/content.d.ts CHANGED
@@ -26,7 +26,6 @@ export type Werkbank = {
26
26
  };
27
27
  export declare const entryFields: (schema: unknown, list: string) => Record<string, FieldKind>;
28
28
  export declare const storyStandIns: (schema: unknown, list: string) => Record<string, string>;
29
- export declare const withStandIns: <T>(item: T, standIns: Readonly<Record<string, string>>) => T;
30
29
  export type Forms = {
31
30
  anmeldung: Readonly<Record<string, string>>;
32
31
  kontakt: Readonly<Record<string, {
package/dist/content.js CHANGED
@@ -38,20 +38,6 @@ export const storyStandIns = (schema, list) => {
38
38
  : [];
39
39
  }));
40
40
  };
41
- // A short text for the story beside the long one for the page: filled, it
42
- // takes the place of the long one in every block that shows it.
43
- export const withStandIns = (item, standIns) => {
44
- if (typeof item !== 'object' || item === null)
45
- return item;
46
- const entry = item;
47
- const filled = Object.entries(standIns).filter(([from]) => typeof entry[from] === 'string' && entry[from].trim() !== '');
48
- if (filled.length === 0)
49
- return item;
50
- return {
51
- ...entry,
52
- ...Object.fromEntries(filled.map(([from, to]) => [to, entry[from]])),
53
- };
54
- };
55
41
  const readJson = (file) => JSON.parse(readFileSync(file, 'utf8'));
56
42
  // Written by the werkbank before every build: per event with registration the
57
43
  // booking page, per contact form where it posts to plus a signed token.
@@ -153,7 +153,10 @@ export interface StorySeries {
153
153
  config: StorySeriesConfig;
154
154
  items: readonly Readonly<Record<string, unknown>>[];
155
155
  fields: Readonly<Record<string, FieldKind>>;
156
+ /** From `x-story-for`: a field to the one it stands in for - the preview needs it for entries saved since. */
157
+ standIns?: Readonly<Record<string, string>>;
156
158
  }
159
+ export declare const withStandIns: <T>(item: T, standIns: Readonly<Record<string, string>>) => T;
157
160
  export declare const seriesTexts: (config: StorySeriesConfig) => {
158
161
  kicker: string | undefined;
159
162
  footer: string | undefined;
@@ -54,6 +54,20 @@ export const BLOCK_COLORS = ['text', 'primary', 'secondary'];
54
54
  export const BLOCK_ICONS = ['none', 'calendar', 'clock', 'location'];
55
55
  /** The source of a block that shows a text of its own, not a field. */
56
56
  export const FIXED_TEXT = 'fixed';
57
+ // A short text for the story beside the long one for the page: filled, it
58
+ // takes the place of the long one in every block that shows it.
59
+ export const withStandIns = (item, standIns) => {
60
+ if (typeof item !== 'object' || item === null)
61
+ return item;
62
+ const entry = item;
63
+ const filled = Object.entries(standIns).filter(([from]) => typeof entry[from] === 'string' && entry[from].trim() !== '');
64
+ if (filled.length === 0)
65
+ return item;
66
+ return {
67
+ ...entry,
68
+ ...Object.fromEntries(filled.map(([from, to]) => [to, entry[from]])),
69
+ };
70
+ };
57
71
  // Whatever arrives: a value of the wrong kind counts as empty.
58
72
  const shown = (show, text) => show === false || typeof text !== 'string'
59
73
  ? undefined
@@ -1,4 +1,4 @@
1
- import type { StoriesConfig, StoryPromoConfig, StorySeries } from './story/cards.ts';
1
+ import { type StoriesConfig, type StoryPromoConfig, type StorySeries } from './story/cards.ts';
2
2
  export declare const languages: readonly string[], homeOf: (lang: string) => string, languageOf: (url: URL) => string, pathIn: (url: URL, lang: string) => string, alternates: (url: URL, site: URL | undefined) => {
3
3
  hreflang: string;
4
4
  href: URL;
package/dist/werkbank.js CHANGED
@@ -1,8 +1,9 @@
1
1
  // For a site maintained in the werkbank: languages and sections come from
2
2
  // werkbank/struktur.json, the texts of the code from the site itself.
3
3
  import werkbank from 'virtual:maverick-wave-astro/werkbank';
4
- import { checkTexts, pick, withStandIns } from "./content.js";
4
+ import { checkTexts, pick } from "./content.js";
5
5
  import { languageRouting } from "./languages.js";
6
+ import { withStandIns, } from "./story/cards.js";
6
7
  const routing = languageRouting(werkbank.languages);
7
8
  export const { languages, homeOf, languageOf, pathIn, alternates, localized, switcher, } = routing;
8
9
  const languageFrom = (from) => typeof from === 'string' ? from : languageOf(from);
@@ -51,6 +52,7 @@ export const stories = () => {
51
52
  ? entries.map(item => withStandIns(item, standIns))
52
53
  : [],
53
54
  fields,
55
+ standIns,
54
56
  };
55
57
  }),
56
58
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "maverick-wave-astro",
3
- "version": "1.42.0",
3
+ "version": "1.44.0",
4
4
  "description": "Shared frame for static Astro homepages built with MaverickWave: layout, SEO, design variants, schedule, building blocks.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -53,7 +53,7 @@
53
53
  },
54
54
  "peerDependencies": {
55
55
  "astro": "^7.2.0",
56
- "maverick-wave": "^6.32.0",
56
+ "maverick-wave": "^6.33.0",
57
57
  "vite": "^8.0.0"
58
58
  },
59
59
  "dependencies": {
@@ -70,7 +70,7 @@
70
70
  "eslint-plugin-astro": "^1.5.0",
71
71
  "eslint-plugin-simple-import-sort": "^12.1.1",
72
72
  "globals": "^16.5.0",
73
- "maverick-wave": "^6.32.0",
73
+ "maverick-wave": "^6.33.0",
74
74
  "playwright-core": "^1.64.0",
75
75
  "prettier": "^3.6.2",
76
76
  "prettier-plugin-astro": "^0.14.1",