gatsby-matrix-theme 53.18.6 → 53.19.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,31 @@
1
+ # [53.19.0](https://gitlab.com/g2m-gentoo/team-floyd/themes/matrix-theme/compare/v53.18.7...v53.19.0) (2026-06-10)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * refactor module logic ([75a0c12](https://gitlab.com/g2m-gentoo/team-floyd/themes/matrix-theme/commit/75a0c128f4b439cd91a0f61ef3bc33d42f06fb2f))
7
+
8
+
9
+ ### Config
10
+
11
+ * update theme version ([f1883b6](https://gitlab.com/g2m-gentoo/team-floyd/themes/matrix-theme/commit/f1883b61c9f5b2fd554e76fc5439f00eeabd9579))
12
+
13
+
14
+ * Merge branch 'master' of gitlab.com:g2m-gentoo/team-floyd/themes/matrix-theme ([409a7e4](https://gitlab.com/g2m-gentoo/team-floyd/themes/matrix-theme/commit/409a7e468f20cdd40ac04fb191a98174eaa022ec))
15
+ * Merge branch 'EN-544' into 'master' ([93d692a](https://gitlab.com/g2m-gentoo/team-floyd/themes/matrix-theme/commit/93d692a02fb35b6a6475d26a70f489ecadbffab8))
16
+
17
+
18
+ ### Features
19
+
20
+ * update content module template four style ([e782d51](https://gitlab.com/g2m-gentoo/team-floyd/themes/matrix-theme/commit/e782d514b970e03c290a9801efb2371a10ab776d))
21
+
22
+ ## [53.18.7](https://gitlab.com/g2m-gentoo/team-floyd/themes/matrix-theme/compare/v53.18.6...v53.18.7) (2026-06-08)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * update core version ([bab331f](https://gitlab.com/g2m-gentoo/team-floyd/themes/matrix-theme/commit/bab331f2f8fe8660ccb46de0018e246901c7f539))
28
+
1
29
  ## [53.18.6](https://gitlab.com/g2m-gentoo/team-floyd/themes/matrix-theme/compare/v53.18.5...v53.18.6) (2026-06-02)
2
30
 
3
31
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gatsby-matrix-theme",
3
- "version": "53.18.6",
3
+ "version": "53.19.0",
4
4
  "main": "index.js",
5
5
  "description": "Matrix Theme NPM Package",
6
6
  "author": "",
@@ -26,7 +26,7 @@
26
26
  "@react-icons/all-files": "^4.1.0",
27
27
  "@gigmedia/enigma-utils": "^1.20.0",
28
28
  "gatsby": "^5.11.0",
29
- "gatsby-core-theme": "^44.25.2",
29
+ "gatsby-core-theme": "^44.26.0",
30
30
  "gatsby-plugin-sharp": "^5.11.0",
31
31
  "gatsby-plugin-sitemap": "^6.13.1",
32
32
  "gatsby-transformer-sharp": "^5.11.0",
@@ -0,0 +1,190 @@
1
+ # CMS module router
2
+
3
+ This folder resolves **which React component** to render for each CMS module on a page, and **which props** it receives.
4
+
5
+ Pages are built from CMS data: `page.sections.main.modules[]` → each item has a `name` (e.g. `widget`, `top_list`, `google_preferred_source`). The `Modules` component in `index.js` renders one module at a time.
6
+
7
+ ## File structure
8
+
9
+ | File | Responsibility |
10
+ |------|----------------|
11
+ | `index.js` | Page wrapper: title, intro, Suspense, admin bar. Calls `resolveModule()`. |
12
+ | `module-registry.js` | Maps CMS `module.name` → component, props, and render rules. |
13
+ | `module-constants.js` | Shared lists (sportstake names, modules without Suspense, etc.). |
14
+ | `module-props.js` | Extra prop builders for sportstake/lotto modules. |
15
+ | `module.module.scss` | Layout styles per module (e.g. `.google_preferred_sourceModule`). |
16
+
17
+ Component implementations live under `src/components/` (matrix) or `gatsby-core-theme` (core), **not** in this folder.
18
+
19
+ ## Render flow
20
+
21
+ ```
22
+ CMS module (name, items, title, …)
23
+
24
+ index.js builds context (page, serverData, …)
25
+
26
+ resolveModule(name, context) → module-registry.js
27
+
28
+ null → nothing rendered
29
+ { Component, props, meta } → render inside wrapper <div>
30
+ ```
31
+
32
+ 1. **`resolveModule`** looks up `MODULE_REGISTRY[moduleName]`.
33
+ 2. **`shouldRender`** (optional) can return `false` → module is skipped.
34
+ 3. Component is either a **direct import** (`component`) or **lazy-loaded** (`load`).
35
+ 4. **`getProps`** (optional) returns extra props spread onto the component.
36
+ 5. **`index.js`** wraps the result in the standard module shell (title, intro, Suspense fallback).
37
+
38
+ ## Context (`ctx`)
39
+
40
+ The second argument to `resolveModule` and to registry helpers is a **context object** (not React Context):
41
+
42
+ ```js
43
+ {
44
+ module, // current CMS module
45
+ page, // current page
46
+ pageContext, // full Gatsby page context
47
+ serverData, // SSR data (sportstake, lotto, search, …)
48
+ socialIcons, // from site schema
49
+ EEAT, // site uses EEAT contributors
50
+ isContactUsPage,
51
+ anchorLabel, // anchor id for the wrapper
52
+ }
53
+ ```
54
+
55
+ Use `ctx` inside `shouldRender` and `getProps` when you need page or server data.
56
+
57
+ ## Registry entry options
58
+
59
+ Add one key per CMS module name in `MODULE_REGISTRY` in `module-registry.js`.
60
+
61
+ | Option | Purpose |
62
+ |--------|---------|
63
+ | `component` | Already-imported React component (eager, no `lazy`). |
64
+ | `load` | `() => import('path/to/component')` for code-splitting. |
65
+ | `resolveComponent` | Function `(ctx) => Component` when the component depends on runtime data (e.g. iframe, spotlights). |
66
+ | `shouldRender` | `(module, ctx) => boolean`. Return `false` to hide the module. |
67
+ | `getProps` | `(ctx) => object` merged into the component props. |
68
+ | `suspense: false` | Skip `<Suspense>` wrapper (see `NO_SUSPENSE_MODULES` in constants). |
69
+ | `hideModuleHeader: true` | No module title / intro block (see `HIDE_MODULE_HEADER_MODULES`). |
70
+ | `sportstakeSuspense: true` | Use taller Suspense fallback (sportstake modules). |
71
+
72
+ If `resolveModule` returns `null`, the module is not shown (unknown name, failed `shouldRender`, or no component).
73
+
74
+ ## How to add a new module
75
+
76
+ ### 1. Create the component
77
+
78
+ Example CMS name: `my_banner` → typical path:
79
+
80
+ ```
81
+ src/components/molecules/my-banner/index.js
82
+ ```
83
+
84
+ The CMS `name` uses **snake_case**; folders often use **kebab-case**. They do not have to match, but matching makes discovery easier.
85
+
86
+ ### 2. Register in `module-registry.js`
87
+
88
+ **Simple lazy module (most common):**
89
+
90
+ ```js
91
+ my_banner: {
92
+ load: () => import('../../../../components/molecules/my-banner'),
93
+ },
94
+ ```
95
+
96
+ **Eager component (like `content`):**
97
+
98
+ ```js
99
+ import MyBanner from '../../../../components/molecules/my-banner';
100
+
101
+ // in MODULE_REGISTRY:
102
+ my_banner: {
103
+ component: MyBanner,
104
+ },
105
+ ```
106
+
107
+ **With extra props:**
108
+
109
+ ```js
110
+ my_banner: {
111
+ load: () => import('../../../../components/molecules/my-banner'),
112
+ getProps: ({ page }) => ({ pageTemplate: page?.template }),
113
+ },
114
+ ```
115
+
116
+ **Hide default title/intro (banner-only UI):**
117
+
118
+ ```js
119
+ my_banner: {
120
+ load: () => import('../../../../components/molecules/my-banner'),
121
+ hideModuleHeader: true,
122
+ },
123
+ ```
124
+
125
+ Or add `my_banner` to `HIDE_MODULE_HEADER_MODULES` in `module-constants.js`.
126
+
127
+ **Only render when a condition is met:**
128
+
129
+ ```js
130
+ my_banner: {
131
+ load: () => import('../../../../components/molecules/my-banner'),
132
+ shouldRender: (_, ctx) => Boolean(ctx.page?.someField),
133
+ },
134
+ ```
135
+
136
+ ### 3. Add CMS + styles (if needed)
137
+
138
+ - Add the module in the CMS for the relevant pages/templates.
139
+ - Optional: add `.my_bannerModule { … }` in `module.module.scss` for layout overrides.
140
+
141
+ ### 4. Verify
142
+
143
+ - Add the module on a test page in the CMS.
144
+ - Run `gatsby develop` and confirm it renders.
145
+ - If nothing appears: check `shouldRender`, `resolveModule` returning `null`, or a lazy import path typo.
146
+
147
+ ## Sportstake / lotto modules
148
+
149
+ Do **not** add each sportstake/lotto name manually unless it is a one-off.
150
+
151
+ 1. Add the CMS name to the right array in `module-constants.js` (`SPORTSTAKE_FIXTURE_MODULES`, `SPORTSTAKE_RESULT_MODULES`, or `LOTTO_MODULES`).
152
+ 2. Registry entries for those groups are generated automatically at the bottom of `MODULE_REGISTRY` via `sportstakeFixtureEntries`, `sportstakeResultEntries`, and `lottoEntries`.
153
+ 3. Shared prop logic lives in `module-props.js` (`getSportstakeFixtureProps`, etc.).
154
+
155
+ They require `serverData` from `getServerData` / `server-data.js` and only render when data exists.
156
+
157
+ ## Props passed to every module component
158
+
159
+ Regardless of registry `getProps`, `index.js` always passes:
160
+
161
+ - `module`, `page`, `pageContext`
162
+ - `noModuleIntro`
163
+ - `exclOperator`, `isHomepageFirstModule`, `modulePosition`
164
+ - Plus anything from `getProps` (or `{ anchorLabel }` by default)
165
+
166
+ Your component should accept what it needs via `module` / `page` or document extra props in `getProps`.
167
+
168
+ ## Examples in this codebase
169
+
170
+ | CMS name | Notes |
171
+ |----------|--------|
172
+ | `google_preferred_source` | Matrix molecule; `hideModuleHeader`; env URL in component. |
173
+ | `widget` | Simple `load` entry. |
174
+ | `welcome_bonus` | Different folder name (`operator-welcome-bonus`). |
175
+ | `iframe` / `game_iframe` | `resolveComponent` picks game iframe vs core iframe. |
176
+ | `multiple_contributors` | `shouldRender` + `getProps` for EEAT sites. |
177
+ | `sportstake8fixturesweekend` | Listed in `SPORTSTAKE_FIXTURE_MODULES`, not in registry manually. |
178
+
179
+ ## Import paths
180
+
181
+ - **Matrix components:** `../../../../components/...` (relative from this folder).
182
+ - **Core theme:** `gatsby-core-theme/src/components/...`.
183
+ - **Aliases:** `~atoms/...`, `~molecules/...` where configured.
184
+
185
+ Keep new entries consistent with neighbouring modules in `module-registry.js`.
186
+
187
+ ## Related code
188
+
189
+ - **Where modules are listed on a page:** `gatsby-core-theme` → `Main` → maps over `page.sections.main.modules`.
190
+ - **Server data for sportstake/lotto:** `src/gatsby-core-theme/helpers/server-data.js`.