mirror of
https://github.com/forcedotcom/afv-library.git
synced 2026-08-10 01:32:48 +08:00
2.5 KiB
2.5 KiB
LWR — Patching home/content.json
Target file:
digitalExperiences/site/<siteName>/sfdc_cms__view/home/content.json
The patch is applied by scripts/patch_lwr_bundle.sh. Invoke as:
scripts/patch_lwr_bundle.sh <content.json> <deploymentName> <scrtUrl> <siteEndpoint>
The manual JSON walk is preserved below in manual_fallback.md for cases where the script cannot run (jq missing, unusual template shape, etc.).
What the script does
- Reads
<content.json>withjq. - Walks
.contentBody.component.children[]and locates the region where.type == "region"and.name == "content". - Recursively checks whether any descendant node already has
.definition == "experience_messaging:embeddedMessaging". - If found — updates that node's
.attributesto the six standard values and preserves the existing.id:deploymentName,scrtUrl,siteEndpoint(from CLI args)isExpSiteAuthMode: false,hideChatButtonOnLoad: "Default",clientVersion: "WebV1"
- If absent — appends a fresh
community_layout:sectionwrapper. The wrapper'ssectionConfigis a JSON string (not a nested object), and the UUID insidesectionConfig.columns[0].idmatches the child region'sid. The nested region carriesid,name: "column",title: "Column",type: "region". - Writes the file back with jq's 2-space indentation.
Re-running with the same arguments is a no-op (idempotent); re-running with new deployment coordinates refreshes the attributes in place without changing the component's id.
How to verify
-
Exactly one messaging node exists:
jq '[.. | select(.definition? == "experience_messaging:embeddedMessaging")] | length' <content.json> # → 1 -
sectionConfigis a string, not an object:jq '.. | select(.definition? == "community_layout:section") | .sectionConfig | type' <content.json> # → "string" -
The section's
idand the child region'sidboth appear inside thesectionConfigstring.
Common failures
| Symptom | Cause |
|---|---|
| Deploy succeeds but chat button never appears | sectionConfig was written as an object, not a JSON string |
| Two chat buttons on the page after re-run | Detection did not descend into nested community_layout:section wrappers; the script's recursive check avoids this |
| Deploy error "component not registered" | Used componentName (Aura shape) instead of definition (LWR shape) |
| Section renders but is empty | Nested region is missing type: "region" |