You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add top-level state/stateFile loading for global render state and merge it into every generated page, including the 404 page.
Move shared and custom page state loading into a dedicated module with tests for merge precedence, reserved key protection, and state file validation.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy file name to clipboardExpand all lines: crates/webui-press/README.md
+30Lines changed: 30 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -251,6 +251,8 @@ Shadow DOM components can react to the layout via `:host-context([data-layout="f
251
251
"html": "Released under the MIT License."
252
252
},
253
253
254
+
"stateFile": "./state/site.json",
255
+
254
256
"customPages": {
255
257
"/playground/": {
256
258
"layout": "full",
@@ -269,6 +271,34 @@ Shadow DOM components can react to the layout via `:host-context([data-layout="f
269
271
-**`sidebarGroups`** maps URL prefixes to sidebar definitions. The longest matching prefix wins. A page at `/guide/concepts/` uses the `/guide/` sidebar.
270
272
-**`prev`/`next`** links at the bottom of a page are derived from the active sidebar's flat link order.
271
273
274
+
### Shared state
275
+
276
+
Use top-level `state` or `stateFile` when every page needs the same project data:
277
+
278
+
```json
279
+
{
280
+
"stateFile": "./state/site.json"
281
+
}
282
+
```
283
+
284
+
The JSON must be an object and is merged into every page's render state, so
285
+
components and Markdown-authored custom elements can bind to it directly:
286
+
287
+
```html
288
+
<span>{{release.version}}</span>
289
+
```
290
+
291
+
Shared state cannot override reserved docs keys such as `site`, `navigation`,
`headTags`, `label`, or `icon`. Global state is applied first. Custom page
294
+
state is applied afterward for that page, so non-reserved custom page keys can
295
+
override global keys.
296
+
297
+
The merged render state is embedded into each generated page's `#webui-data`
298
+
hydration block. Do not put secrets in `state` or `stateFile`, and keep shared
299
+
state small. Large global JSON files are duplicated into every output page; use
300
+
custom page state or static JSON assets for large page-specific datasets.
301
+
272
302
### `head` injection
273
303
274
304
Every entry in `head[]` is rendered into `<head>` with attributes sorted alphabetically (deterministic output for reproducible builds). Use it for favicons, analytics tags, preloads, OpenGraph overrides, anything `<head>`-shaped.
0 commit comments