@bettercms-ai/sdk 1.12.1 → 1.13.1
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 +11 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +41 -5
- package/dist/index.d.ts +41 -5
- package/dist/index.js +11 -2
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -833,6 +833,7 @@ async function getManagedLayout(client, opts) {
|
|
|
833
833
|
const query = new URLSearchParams();
|
|
834
834
|
if (opts?.scope) query.set("scope", opts.scope);
|
|
835
835
|
if (opts?.pageId) query.set("pageId", opts.pageId);
|
|
836
|
+
if (opts?.copy) query.set("preview", opts.copy);
|
|
836
837
|
const result = await client.fetchJSON(
|
|
837
838
|
client.url(`/management/layout${query.size ? `?${query}` : ""}`),
|
|
838
839
|
opts?.projectId ? { headers: { "X-BCMS-Project": opts.projectId } } : void 0
|
|
@@ -1363,12 +1364,20 @@ function decodeEntities(s) {
|
|
|
1363
1364
|
}
|
|
1364
1365
|
|
|
1365
1366
|
// src/seo.ts
|
|
1367
|
+
function derivedCanonical({ siteUrl, path }) {
|
|
1368
|
+
if (!siteUrl || !path) return "";
|
|
1369
|
+
try {
|
|
1370
|
+
return new URL(path, siteUrl.endsWith("/") ? siteUrl : `${siteUrl}/`).toString();
|
|
1371
|
+
} catch {
|
|
1372
|
+
return "";
|
|
1373
|
+
}
|
|
1374
|
+
}
|
|
1366
1375
|
function jsonLdNodes(schema) {
|
|
1367
1376
|
if (!schema) return [];
|
|
1368
1377
|
const arr = Array.isArray(schema) ? schema : [schema];
|
|
1369
1378
|
return arr.filter((node) => node && Object.keys(node).length > 0);
|
|
1370
1379
|
}
|
|
1371
|
-
function resolveSeo(page, defaults = {}) {
|
|
1380
|
+
function resolveSeo(page, defaults = {}, location = {}) {
|
|
1372
1381
|
const meta = page.metaJson ?? {};
|
|
1373
1382
|
const title = page.metaTitle || page.title || "";
|
|
1374
1383
|
const description = page.metaDescription || defaults.metaDescription || "";
|
|
@@ -1376,7 +1385,7 @@ function resolveSeo(page, defaults = {}) {
|
|
|
1376
1385
|
const ogTitle = meta.og?.title || title;
|
|
1377
1386
|
const ogDescription = meta.og?.description || description;
|
|
1378
1387
|
const twImage = meta.twitter?.image || ogImage;
|
|
1379
|
-
const canonical = meta.canonical ||
|
|
1388
|
+
const canonical = meta.canonical || derivedCanonical(location);
|
|
1380
1389
|
return {
|
|
1381
1390
|
title,
|
|
1382
1391
|
description,
|