Widget Implementation
Browser Widget Implementation
Use this checklist when adding or changing a browser widget.
Wiring Path
- Authoring source:
- shortcode, fenced codeblock, front matter, or data file.
- Hugo render path:
- partial or render hook emits semantic, stable DOM;
- include data attributes needed by the runtime;
- avoid inline styles/scripts unless there is a narrow reason.
- Runtime:
- add or update
cdn/custom/<widget>.js; - register initialization through
window.QL.runtimeor the existing widget runtime compatibility path; - handle SPA route swaps and repeated initialization safely.
- add or update
- Styles:
- alias site tokens into widget-local variables;
- reset global component leakage inside the widget root;
- keep controls explicit and accessible.
- Asset loading:
- add shared runtime assets through the generator head/CDN pipeline;
- avoid site-local head forks.
- Docs and tests:
- update authoring docs and module map;
- run a Hugo render check and a browser smoke when behavior is interactive.
Runtime Rules
- Initialization must be idempotent.
- Widgets should tolerate SPA replacement of the page body.
- Widgets should not assume a static header or global singleton page.
- Network/auth probes should use the shared guarded patterns when touching protected routes.
Files To Read
docs/widget-integration-plan.mddocs/javascript-module-map.mdcdn/custom/widgetRuntime.js- existing widget runtimes under
cdn/custom/*Widget.js - relevant Hugo shortcode/render-hook partials