@ohhwells/bridge 0.1.125 → 0.1.126

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/dist/index.cjs CHANGED
@@ -296,10 +296,14 @@ function reapRemovedAiSections(state, store, removedIds, excludeIds = /* @__PURE
296
296
  var BRAND_NAME_KEY = "__ohw_brand_name";
297
297
  var BRAND_TITLE_KEY = "__ohw_site_title";
298
298
  var BRAND_FAVICON_LETTER_KEY = "__ohw_favicon_letter";
299
+ var SITE_DESCRIPTION_KEY = "__ohw_site_description";
300
+ var SITE_OG_IMAGE_KEY = "__ohw_og_image";
299
301
  var BRAND_CHROME_KEYS = /* @__PURE__ */ new Set([
300
302
  BRAND_NAME_KEY,
301
303
  BRAND_TITLE_KEY,
302
- BRAND_FAVICON_LETTER_KEY
304
+ BRAND_FAVICON_LETTER_KEY,
305
+ SITE_DESCRIPTION_KEY,
306
+ SITE_OG_IMAGE_KEY
303
307
  ]);
304
308
  function upsertMeta(selector, attr, token, value) {
305
309
  let el = document.head.querySelector(selector);
@@ -310,6 +314,9 @@ function upsertMeta(selector, attr, token, value) {
310
314
  }
311
315
  if (el.getAttribute("content") !== value) el.setAttribute("content", value);
312
316
  }
317
+ function removeMeta(selector) {
318
+ document.head.querySelector(selector)?.remove();
319
+ }
313
320
  function escapeXml(value) {
314
321
  return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
315
322
  }
@@ -325,6 +332,22 @@ function applyLetterFavicon(letter) {
325
332
  link.type = "image/svg+xml";
326
333
  if (link.href !== href) link.href = href;
327
334
  }
335
+ function applyDescription(description) {
336
+ if (!description) return;
337
+ upsertMeta('meta[name="description"]', "name", "description", description);
338
+ upsertMeta('meta[property="og:description"]', "property", "og:description", description);
339
+ upsertMeta('meta[name="twitter:description"]', "name", "twitter:description", description);
340
+ }
341
+ function applyOgImage(url) {
342
+ if (url) {
343
+ upsertMeta('meta[property="og:image"]', "property", "og:image", url);
344
+ upsertMeta('meta[name="twitter:image"]', "name", "twitter:image", url);
345
+ upsertMeta('meta[name="twitter:card"]', "name", "twitter:card", "summary_large_image");
346
+ return;
347
+ }
348
+ removeMeta('meta[property="og:image"]');
349
+ removeMeta('meta[name="twitter:image"]');
350
+ }
328
351
  function applyBrandChrome(content) {
329
352
  const name = content[BRAND_NAME_KEY];
330
353
  if (typeof name === "string" && name.length > 0) {
@@ -343,6 +366,13 @@ function applyBrandChrome(content) {
343
366
  if (typeof letter === "string" && letter.length > 0) {
344
367
  applyLetterFavicon(letter);
345
368
  }
369
+ const description = content[SITE_DESCRIPTION_KEY];
370
+ if (typeof description === "string" && description.length > 0) {
371
+ applyDescription(description);
372
+ }
373
+ if (Object.prototype.hasOwnProperty.call(content, SITE_OG_IMAGE_KEY)) {
374
+ applyOgImage(String(content[SITE_OG_IMAGE_KEY] ?? "").trim());
375
+ }
346
376
  }
347
377
 
348
378
  // src/lib/brand-kit.ts
@@ -26137,6 +26167,21 @@ function OhhwellsBridge() {
26137
26167
  type: "text",
26138
26168
  text: editContentRef.current[CUSTOM_CODE_AFTER_HEAD_KEY] ?? ""
26139
26169
  });
26170
+ nodes.push({
26171
+ key: BRAND_TITLE_KEY,
26172
+ type: "text",
26173
+ text: editContentRef.current[BRAND_TITLE_KEY] ?? ""
26174
+ });
26175
+ nodes.push({
26176
+ key: SITE_DESCRIPTION_KEY,
26177
+ type: "text",
26178
+ text: editContentRef.current[SITE_DESCRIPTION_KEY] ?? ""
26179
+ });
26180
+ nodes.push({
26181
+ key: SITE_OG_IMAGE_KEY,
26182
+ type: "text",
26183
+ text: editContentRef.current[SITE_OG_IMAGE_KEY] ?? ""
26184
+ });
26140
26185
  document.querySelectorAll('[data-ohw-editable="form"]').forEach((form) => {
26141
26186
  const formKey = formKeyOf(form);
26142
26187
  if (!formKey) return;
@@ -26890,7 +26935,7 @@ function OhhwellsBridge() {
26890
26935
  postToParent2({
26891
26936
  type: "ow:ready",
26892
26937
  version: "1",
26893
- bridgeVersion: "0.1.124",
26938
+ bridgeVersion: "0.1.125",
26894
26939
  path: pathname,
26895
26940
  nodes: collectEditableNodes(editContentRef.current),
26896
26941
  sections