@bettercms-ai/sdk 1.12.0 → 1.13.0

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
@@ -1363,12 +1363,20 @@ function decodeEntities(s) {
1363
1363
  }
1364
1364
 
1365
1365
  // src/seo.ts
1366
+ function derivedCanonical({ siteUrl, path }) {
1367
+ if (!siteUrl || !path) return "";
1368
+ try {
1369
+ return new URL(path, siteUrl.endsWith("/") ? siteUrl : `${siteUrl}/`).toString();
1370
+ } catch {
1371
+ return "";
1372
+ }
1373
+ }
1366
1374
  function jsonLdNodes(schema) {
1367
1375
  if (!schema) return [];
1368
1376
  const arr = Array.isArray(schema) ? schema : [schema];
1369
1377
  return arr.filter((node) => node && Object.keys(node).length > 0);
1370
1378
  }
1371
- function resolveSeo(page, defaults = {}) {
1379
+ function resolveSeo(page, defaults = {}, location = {}) {
1372
1380
  const meta = page.metaJson ?? {};
1373
1381
  const title = page.metaTitle || page.title || "";
1374
1382
  const description = page.metaDescription || defaults.metaDescription || "";
@@ -1376,7 +1384,7 @@ function resolveSeo(page, defaults = {}) {
1376
1384
  const ogTitle = meta.og?.title || title;
1377
1385
  const ogDescription = meta.og?.description || description;
1378
1386
  const twImage = meta.twitter?.image || ogImage;
1379
- const canonical = meta.canonical || "";
1387
+ const canonical = meta.canonical || derivedCanonical(location);
1380
1388
  return {
1381
1389
  title,
1382
1390
  description,