@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 +47 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +47 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -222,10 +222,14 @@ function reapRemovedAiSections(state, store, removedIds, excludeIds = /* @__PURE
|
|
|
222
222
|
var BRAND_NAME_KEY = "__ohw_brand_name";
|
|
223
223
|
var BRAND_TITLE_KEY = "__ohw_site_title";
|
|
224
224
|
var BRAND_FAVICON_LETTER_KEY = "__ohw_favicon_letter";
|
|
225
|
+
var SITE_DESCRIPTION_KEY = "__ohw_site_description";
|
|
226
|
+
var SITE_OG_IMAGE_KEY = "__ohw_og_image";
|
|
225
227
|
var BRAND_CHROME_KEYS = /* @__PURE__ */ new Set([
|
|
226
228
|
BRAND_NAME_KEY,
|
|
227
229
|
BRAND_TITLE_KEY,
|
|
228
|
-
BRAND_FAVICON_LETTER_KEY
|
|
230
|
+
BRAND_FAVICON_LETTER_KEY,
|
|
231
|
+
SITE_DESCRIPTION_KEY,
|
|
232
|
+
SITE_OG_IMAGE_KEY
|
|
229
233
|
]);
|
|
230
234
|
function upsertMeta(selector, attr, token, value) {
|
|
231
235
|
let el = document.head.querySelector(selector);
|
|
@@ -236,6 +240,9 @@ function upsertMeta(selector, attr, token, value) {
|
|
|
236
240
|
}
|
|
237
241
|
if (el.getAttribute("content") !== value) el.setAttribute("content", value);
|
|
238
242
|
}
|
|
243
|
+
function removeMeta(selector) {
|
|
244
|
+
document.head.querySelector(selector)?.remove();
|
|
245
|
+
}
|
|
239
246
|
function escapeXml(value) {
|
|
240
247
|
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
241
248
|
}
|
|
@@ -251,6 +258,22 @@ function applyLetterFavicon(letter) {
|
|
|
251
258
|
link.type = "image/svg+xml";
|
|
252
259
|
if (link.href !== href) link.href = href;
|
|
253
260
|
}
|
|
261
|
+
function applyDescription(description) {
|
|
262
|
+
if (!description) return;
|
|
263
|
+
upsertMeta('meta[name="description"]', "name", "description", description);
|
|
264
|
+
upsertMeta('meta[property="og:description"]', "property", "og:description", description);
|
|
265
|
+
upsertMeta('meta[name="twitter:description"]', "name", "twitter:description", description);
|
|
266
|
+
}
|
|
267
|
+
function applyOgImage(url) {
|
|
268
|
+
if (url) {
|
|
269
|
+
upsertMeta('meta[property="og:image"]', "property", "og:image", url);
|
|
270
|
+
upsertMeta('meta[name="twitter:image"]', "name", "twitter:image", url);
|
|
271
|
+
upsertMeta('meta[name="twitter:card"]', "name", "twitter:card", "summary_large_image");
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
removeMeta('meta[property="og:image"]');
|
|
275
|
+
removeMeta('meta[name="twitter:image"]');
|
|
276
|
+
}
|
|
254
277
|
function applyBrandChrome(content) {
|
|
255
278
|
const name = content[BRAND_NAME_KEY];
|
|
256
279
|
if (typeof name === "string" && name.length > 0) {
|
|
@@ -269,6 +292,13 @@ function applyBrandChrome(content) {
|
|
|
269
292
|
if (typeof letter === "string" && letter.length > 0) {
|
|
270
293
|
applyLetterFavicon(letter);
|
|
271
294
|
}
|
|
295
|
+
const description = content[SITE_DESCRIPTION_KEY];
|
|
296
|
+
if (typeof description === "string" && description.length > 0) {
|
|
297
|
+
applyDescription(description);
|
|
298
|
+
}
|
|
299
|
+
if (Object.prototype.hasOwnProperty.call(content, SITE_OG_IMAGE_KEY)) {
|
|
300
|
+
applyOgImage(String(content[SITE_OG_IMAGE_KEY] ?? "").trim());
|
|
301
|
+
}
|
|
272
302
|
}
|
|
273
303
|
|
|
274
304
|
// src/lib/brand-kit.ts
|
|
@@ -26069,6 +26099,21 @@ function OhhwellsBridge() {
|
|
|
26069
26099
|
type: "text",
|
|
26070
26100
|
text: editContentRef.current[CUSTOM_CODE_AFTER_HEAD_KEY] ?? ""
|
|
26071
26101
|
});
|
|
26102
|
+
nodes.push({
|
|
26103
|
+
key: BRAND_TITLE_KEY,
|
|
26104
|
+
type: "text",
|
|
26105
|
+
text: editContentRef.current[BRAND_TITLE_KEY] ?? ""
|
|
26106
|
+
});
|
|
26107
|
+
nodes.push({
|
|
26108
|
+
key: SITE_DESCRIPTION_KEY,
|
|
26109
|
+
type: "text",
|
|
26110
|
+
text: editContentRef.current[SITE_DESCRIPTION_KEY] ?? ""
|
|
26111
|
+
});
|
|
26112
|
+
nodes.push({
|
|
26113
|
+
key: SITE_OG_IMAGE_KEY,
|
|
26114
|
+
type: "text",
|
|
26115
|
+
text: editContentRef.current[SITE_OG_IMAGE_KEY] ?? ""
|
|
26116
|
+
});
|
|
26072
26117
|
document.querySelectorAll('[data-ohw-editable="form"]').forEach((form) => {
|
|
26073
26118
|
const formKey = formKeyOf(form);
|
|
26074
26119
|
if (!formKey) return;
|
|
@@ -26822,7 +26867,7 @@ function OhhwellsBridge() {
|
|
|
26822
26867
|
postToParent2({
|
|
26823
26868
|
type: "ow:ready",
|
|
26824
26869
|
version: "1",
|
|
26825
|
-
bridgeVersion: "0.1.
|
|
26870
|
+
bridgeVersion: "0.1.125",
|
|
26826
26871
|
path: pathname,
|
|
26827
26872
|
nodes: collectEditableNodes(editContentRef.current),
|
|
26828
26873
|
sections
|