Skip to content

Commit 233902a

Browse files
authored
feat: use query params for embedded views (#330)
Before Submitting This PR, Please Ensure You Have Completed The Following: 1. [ ] Are internal links to wiki documents using [relative file links](https://docusaurus.io/docs/markdown-features/links)? 2. [ ] Are all new documentation files lowercase, with dash separated names (ex. unraid-os.mdx)? 3. [ ] Are all assets (images, etc), located in an assets/ subfolder next to the .md/mdx files? 4. [ ] Have you checked to ensure there aren't other open [Pull Requests](../../../pulls) for the same update/change? 5. [ ] Is the build succeeding? <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - New Features - Full iframe embedding support with URL-driven configuration for embed, theme, entry, and sidebar; host messaging for readiness, theme, and navigation; in-iframe back navigation and persisted iframe state. - Style - Auto-hide sidebar/TOC when sidebar disabled, expand content to full width, and add a fixed back-button UI. - Documentation - Comprehensive embedding guide with parameter usage, session keys, example URL builder, host integration flow, and demo test page. - Tests - New tests covering embed messaging, message handling, and legacy compatibility. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent eb26490 commit 233902a

File tree

11 files changed

+1051
-213
lines changed

11 files changed

+1051
-213
lines changed

docs/embedding.md

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# Embedding Unraid Docs
2+
3+
Use the following guidance when loading the Unraid documentation inside an iframe-driven experience. Query parameters cover the most common configuration options, and an optional `postMessage` API is available for hosts that need dynamic coordination.
4+
5+
## Required Query Parameters
6+
7+
- `embed=1` — Opts the page into iframe-specific presentation tweaks (hides the global navbar, footer, etc.). Include this on every embedded URL.
8+
9+
## Optional Query Parameters
10+
11+
- `theme=<light|dark>` — Forces the initial Docs theme. The value is persisted for the iframe session so reloads stay consistent.
12+
- `entry=<path>` — Marks the logical entry point for the iframe session. Supply an absolute docs path (e.g. `/unraid-os/...`) or a full docs URL; the embedded UI shows a floating back icon that returns visitors to this path and hides itself while you remain on it. Defaults to the first loaded URL if omitted.
13+
- `sidebar=1` — Re-enables the documentation sidebar and table of contents, which are hidden by default in embedded mode.
14+
15+
## Session Storage Keys
16+
17+
The iframe experience uses `window.sessionStorage` to remember state while a browser tab stays open. Host applications normally do not need to interact with these keys, but they are listed here for completeness.
18+
19+
| Key | Purpose |
20+
| --- | --- |
21+
| `unraidDocsIframe` | Tracks whether the current session originated inside an iframe. |
22+
| `unraidDocsTheme` | Stores the last used Docs theme so reloads stay consistent. |
23+
| `unraidDocsIframeEntry` | Holds the iframe entry path for the fallback back button. |
24+
| `unraidDocsIframeSidebar` | Marks whether the sidebar was explicitly enabled. |
25+
26+
A host can clear these keys to reset the embedded state before opening a new iframe session.
27+
28+
## Example URL Builders
29+
30+
```js
31+
function buildDocsUrl(path, { theme, entry, sidebar } = {}) {
32+
const url = new URL(path, "https://docs.unraid.net");
33+
url.searchParams.set("embed", "1");
34+
35+
if (theme === "light" || theme === "dark") {
36+
url.searchParams.set("theme", theme);
37+
}
38+
39+
if (entry) {
40+
url.searchParams.set("entry", entry);
41+
}
42+
43+
if (sidebar) {
44+
url.searchParams.set("sidebar", "1");
45+
}
46+
47+
return url.toString();
48+
}
49+
```
50+
51+
## Recommended Host Flow
52+
53+
1. Decide which route should serve as the iframe entry point and supply it via `entry` when loading the iframe.
54+
2. Pass the current host theme if you want the Docs theme to match immediately.
55+
3. Toggle `sidebar=1` only when the host layout can accommodate the wider viewport required for the sidebar.
56+
4. When tearing down an iframe session, optionally clear the session-storage keys to remove residual state before launching a new session in the same tab.
57+
58+
## Messaging API
59+
60+
The embedded docs surface a lightweight `postMessage` API that reports readiness, navigation, and theme changes using structured message types. All messages share the shape `{ source: "unraid-docs", type: string, ...payload }` so hosts can quickly filter for docs-specific traffic.
61+
62+
### Messages emitted from the iframe
63+
64+
| Type | Payload | Purpose |
65+
| --- | --- | --- |
66+
| `unraid-docs:ready` | `{ theme: "light" \| "dark" }` | Fired once the iframe has applied its starting theme. |
67+
| `unraid-docs:theme-change` | `{ theme: "light" \| "dark" }` | Fired whenever the iframe theme changes (including the initial emission). |
68+
| `unraid-docs:navigation` | `{ pathname, search, hash, url }` | Fired whenever in-iframe navigation occurs. |
69+
70+
### Commands accepted by the iframe
71+
72+
| Type | Payload | Purpose |
73+
| --- | --- | --- |
74+
| `unraid-docs:set-theme` | `{ theme: "light" \| "dark" }` | Requests a theme change without requiring a reload. |
75+
76+
Example host handler:
77+
78+
```js
79+
window.addEventListener('message', (event) => {
80+
const data = event.data;
81+
if (!data || data.source !== 'unraid-docs') {
82+
return;
83+
}
84+
85+
if (data.type === 'unraid-docs:theme-change') {
86+
console.log('Docs theme changed to', data.theme);
87+
}
88+
});
89+
90+
function setIframeTheme(frame, theme) {
91+
if (!frame.contentWindow) {
92+
return;
93+
}
94+
95+
frame.contentWindow.postMessage({
96+
source: 'unraid-docs',
97+
type: 'unraid-docs:set-theme',
98+
theme,
99+
}, '*');
100+
}
101+
```
102+
103+
Refer to `iframe-test.html` for a working example that exercises both outgoing and incoming messages.
104+
105+
### Legacy compatibility
106+
107+
For backwards compatibility the iframe still listens for `{ type: "theme-update", theme }` and continues to emit the historical `theme-ready` and `theme-changed` messages alongside the new message types. Hosts should migrate to the structured `unraid-docs:*` contract because the legacy events will be removed in a future release. The example test page also demonstrates how to broadcast both message formats during the transition period.

docs/unraid-os/release-notes/7.2.0.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -176,19 +176,19 @@ Login to the Unraid webGUI using Single Sign‑On (SSO) with your Unraid.net acc
176176
### Linux kernel
177177

178178
- version 6.12.47-Unraid \[-beta.3]
179-
- built-in: CONFIG_EFIVAR_FS: EFI Variable filesystem
180-
- CONFIG_INTEL_RAPL: Intel RAPL support via MSR interface
179+
- built-in: CONFIG\_EFIVAR\_FS: EFI Variable filesystem
180+
- CONFIG\_INTEL\_RAPL: Intel RAPL support via MSR interface
181181
- Added eMMC support: \[-beta.3]
182-
- CONFIG_MMC: MMC/SD/SDIO card support
183-
- CONFIG_MMC_BLOCK: MMC block device driver
184-
- CONFIG_MMC_SDHCI: Secure Digital Host Controller Interface support
185-
- CONFIG_MMC_SDHCI_PCI: SDHCI support on PCI bus
186-
- CONFIG_MMC_SDHCI_ACPI: SDHCI support for ACPI enumerated SDHCI controllers
187-
- CONFIG_MMC_SDHCI_PLTFM: SDHCI platform and OF driver helper
182+
- CONFIG\_MMC: MMC/SD/SDIO card support
183+
- CONFIG\_MMC\_BLOCK: MMC block device driver
184+
- CONFIG\_MMC\_SDHCI: Secure Digital Host Controller Interface support
185+
- CONFIG\_MMC\_SDHCI\_PCI: SDHCI support on PCI bus
186+
- CONFIG\_MMC\_SDHCI\_ACPI: SDHCI support for ACPI enumerated SDHCI controllers
187+
- CONFIG\_MMC\_SDHCI\_PLTFM: SDHCI platform and OF driver helper
188188

189189
### Base distro updates
190190

191-
- aaa_glibc-solibs: version 2.42
191+
- aaa\_glibc-solibs: version 2.42
192192
- adwaita-icon-theme: version 48.1
193193
- at-spi2-core: version 2.56.4
194194
- bash: version 5.3.003
@@ -218,7 +218,7 @@ Login to the Unraid webGUI using Single Sign‑On (SSO) with your Unraid.net acc
218218
- iputils: version 20250605
219219
- iw: version 6.17
220220
- kbd: version 2.8.0
221-
- kernel-firmware: version 20250909_4573c02
221+
- kernel-firmware: version 20250909\_4573c02
222222
- krb5: version 1.22
223223
- less: version 679
224224
- libXfixes: version 6.0.2
@@ -245,7 +245,7 @@ Login to the Unraid webGUI using Single Sign‑On (SSO) with your Unraid.net acc
245245
- mcelog: version 206
246246
- mesa: version 25.2.2
247247
- nano: version 8.6
248-
- ncurses: version 6.5_20250816
248+
- ncurses: version 6.5\_20250816
249249
- nettle: version 3.10.2
250250
- nghttp2: version 1.67.0
251251
- nghttp3: version 1.11.0
@@ -259,9 +259,9 @@ Login to the Unraid webGUI using Single Sign‑On (SSO) with your Unraid.net acc
259259
- pango: version 1.56.4
260260
- pciutils: version 3.14.0
261261
- perl: version 5.42.0
262-
- php: version 8.3.21-x86_64-1_LT with gettext extension
262+
- php: version 8.3.21-x86\_64-1\_LT with gettext extension
263263
- pixman: version 0.46.4
264-
- rclone: version 1.70.1-x86_64-1_SBo_LT.tgz
264+
- rclone: version 1.70.1-x86\_64-1\_SBo\_LT.tgz
265265
- readline: version 8.3.001
266266
- samba: version 4.22.2
267267
- shadow: version 4.18.0
@@ -284,4 +284,4 @@ Login to the Unraid webGUI using Single Sign‑On (SSO) with your Unraid.net acc
284284
- xkeyboard-config: version 2.45
285285
- xorg-server: version 21.1.18
286286
- xterm: version 402
287-
- zfs: version zfs-2.3.4_6.12.47_Unraid-x86_64-2_LT
287+
- zfs: version zfs-2.3.4\_6.12.47\_Unraid-x86\_64-2\_LT

0 commit comments

Comments
 (0)