@ohhwells/bridge 0.1.122-next.338 → 0.1.122-next.342
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 +46 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +46 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
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
|
|
@@ -26176,6 +26206,21 @@ function OhhwellsBridge() {
|
|
|
26176
26206
|
type: "text",
|
|
26177
26207
|
text: editContentRef.current[CUSTOM_CODE_AFTER_HEAD_KEY] ?? ""
|
|
26178
26208
|
});
|
|
26209
|
+
nodes.push({
|
|
26210
|
+
key: BRAND_TITLE_KEY,
|
|
26211
|
+
type: "text",
|
|
26212
|
+
text: editContentRef.current[BRAND_TITLE_KEY] ?? ""
|
|
26213
|
+
});
|
|
26214
|
+
nodes.push({
|
|
26215
|
+
key: SITE_DESCRIPTION_KEY,
|
|
26216
|
+
type: "text",
|
|
26217
|
+
text: editContentRef.current[SITE_DESCRIPTION_KEY] ?? ""
|
|
26218
|
+
});
|
|
26219
|
+
nodes.push({
|
|
26220
|
+
key: SITE_OG_IMAGE_KEY,
|
|
26221
|
+
type: "text",
|
|
26222
|
+
text: editContentRef.current[SITE_OG_IMAGE_KEY] ?? ""
|
|
26223
|
+
});
|
|
26179
26224
|
document.querySelectorAll('[data-ohw-editable="form"]').forEach((form) => {
|
|
26180
26225
|
const formKey = formKeyOf(form);
|
|
26181
26226
|
if (!formKey) return;
|