@unhead/schema-org 1.8.7 → 1.8.9

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/README.md CHANGED
@@ -1,4 +1,4 @@
1
- #
1
+ #
2
2
 
3
3
  Schema.org for Vue. Supports typed and automated Google Rich Results
4
4
 
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const plugin = require('./shared/schema-org.f81cbd4d.cjs');
3
+ const plugin = require('./shared/schema-org.da628d24.cjs');
4
4
  const unhead = require('unhead');
5
5
  require('@unhead/shared');
6
6
  require('ufo');
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { U as UnheadSchemaOrg } from './shared/schema-org.cefa8818.mjs';
2
- export { H as HowToId, a1 as PluginSchemaOrg, P as PrimaryArticleId, k as PrimaryBookId, m as PrimaryBreadcrumbId, s as PrimaryEventId, X as PrimaryWebPageId, _ as PrimaryWebSiteId, M as ProductId, R as RecipeId, a2 as SchemaOrgUnheadPlugin, L as addressResolver, g as aggregateOfferResolver, h as aggregateRatingResolver, i as articleResolver, j as bookEditionResolver, l as bookResolver, o as breadcrumbResolver, p as commentResolver, q as courseResolver, c as createSchemaOrgGraph, a as dedupeNodes, d as defineSchemaOrgResolver, t as eventResolver, w as foodEstablishmentResolver, x as howToResolver, z as howToStepDirectionResolver, y as howToStepResolver, B as imageResolver, A as itemListResolver, C as jobPostingResolver, D as listItemResolver, E as localBusinessResolver, F as movieResolver, n as normaliseNodes, G as offerResolver, I as openingHoursResolver, J as organizationResolver, K as personResolver, u as placeResolver, N as productResolver, O as questionResolver, Q as ratingResolver, Z as readActionResolver, S as recipeResolver, r as resolveMeta, b as resolveNode, e as resolveNodeId, f as resolveRelation, V as reviewResolver, a0 as searchActionResolver, T as softwareAppResolver, W as videoResolver, v as virtualLocationResolver, Y as webPageResolver, $ as webSiteResolver } from './shared/schema-org.cefa8818.mjs';
1
+ import { U as UnheadSchemaOrg } from './shared/schema-org.bb03b192.mjs';
2
+ export { H as HowToId, a1 as PluginSchemaOrg, P as PrimaryArticleId, k as PrimaryBookId, m as PrimaryBreadcrumbId, s as PrimaryEventId, X as PrimaryWebPageId, _ as PrimaryWebSiteId, M as ProductId, R as RecipeId, a2 as SchemaOrgUnheadPlugin, L as addressResolver, g as aggregateOfferResolver, h as aggregateRatingResolver, i as articleResolver, j as bookEditionResolver, l as bookResolver, o as breadcrumbResolver, p as commentResolver, q as courseResolver, c as createSchemaOrgGraph, a as dedupeNodes, d as defineSchemaOrgResolver, t as eventResolver, w as foodEstablishmentResolver, x as howToResolver, z as howToStepDirectionResolver, y as howToStepResolver, B as imageResolver, A as itemListResolver, C as jobPostingResolver, D as listItemResolver, E as localBusinessResolver, F as movieResolver, n as normaliseNodes, G as offerResolver, I as openingHoursResolver, J as organizationResolver, K as personResolver, u as placeResolver, N as productResolver, O as questionResolver, Q as ratingResolver, Z as readActionResolver, S as recipeResolver, r as resolveMeta, b as resolveNode, e as resolveNodeId, f as resolveRelation, V as reviewResolver, a0 as searchActionResolver, T as softwareAppResolver, W as videoResolver, v as virtualLocationResolver, Y as webPageResolver, $ as webSiteResolver } from './shared/schema-org.bb03b192.mjs';
3
3
  import { getActiveHead, useHead } from 'unhead';
4
4
  import '@unhead/shared';
5
5
  import 'ufo';
@@ -1,5 +1,5 @@
1
1
  import { hashCode, defineHeadPlugin, processTemplateParams } from '@unhead/shared';
2
- import { hasProtocol, joinURL, withBase, withoutTrailingSlash, hasTrailingSlash, withTrailingSlash } from 'ufo';
2
+ import { hasProtocol, withBase, withoutTrailingSlash, hasTrailingSlash, withTrailingSlash, joinURL } from 'ufo';
3
3
 
4
4
  function defineSchemaOrgResolver(schema) {
5
5
  return schema;
@@ -51,7 +51,7 @@ function prefixId(url, id) {
51
51
  return id;
52
52
  if (!id.startsWith("#"))
53
53
  id = `#${id}`;
54
- return joinURL(url, id);
54
+ return withBase(id, url);
55
55
  }
56
56
  function trimLength(val, length) {
57
57
  if (!val)
@@ -293,13 +293,12 @@ const organizationResolver = defineSchemaOrgResolver({
293
293
  resolveRootNode(node, ctx) {
294
294
  const isIdentity = resolveAsGraphKey(node["@id"]) === IdentityId;
295
295
  const webPage = ctx.find(PrimaryWebPageId);
296
- if (node.logo) {
296
+ if (node.logo && isIdentity) {
297
297
  if (!ctx.find("#organization")) {
298
298
  const logoNode = resolveRelation(node.logo, ctx, imageResolver, {
299
299
  root: true,
300
300
  afterResolve(logo) {
301
- if (isIdentity)
302
- logo["@id"] = prefixId(ctx.meta.host, "#logo");
301
+ logo["@id"] = prefixId(ctx.meta.host, "#logo");
303
302
  setIfEmpty(logo, "caption", node.name);
304
303
  }
305
304
  });
@@ -700,6 +699,9 @@ const localBusinessResolver = defineSchemaOrgResolver({
700
699
  node.address = resolveRelation(node.address, ctx, addressResolver);
701
700
  node.openingHoursSpecification = resolveRelation(node.openingHoursSpecification, ctx, openingHoursResolver);
702
701
  node = resolveNode({ ...node }, ctx, organizationResolver);
702
+ return node;
703
+ },
704
+ resolveRootNode(node, ctx) {
703
705
  organizationResolver.resolveRootNode(node, ctx);
704
706
  return node;
705
707
  }
@@ -719,6 +721,10 @@ const foodEstablishmentResolver = defineSchemaOrgResolver({
719
721
  node.starRating = resolveRelation(node.starRating, ctx, ratingResolver);
720
722
  node = resolveNode(node, ctx, localBusinessResolver);
721
723
  return node;
724
+ },
725
+ resolveRootNode(node, ctx) {
726
+ localBusinessResolver.resolveRootNode(node, ctx);
727
+ return node;
722
728
  }
723
729
  });
724
730
 
@@ -1775,30 +1781,29 @@ function resolveNode(node, ctx, resolver) {
1775
1781
  return node;
1776
1782
  }
1777
1783
  function resolveNodeId(node, ctx, resolver, resolveAsRoot = false) {
1778
- const prefix = Array.isArray(resolver.idPrefix) ? resolver.idPrefix[0] : resolver.idPrefix;
1779
- if (!prefix)
1780
- return node;
1781
- if (node["@id"] && !node["@id"].startsWith(ctx.meta.host)) {
1782
- node["@id"] = prefixId(ctx.meta[prefix], node["@id"]);
1784
+ if (node["@id"] && node["@id"].startsWith("http"))
1783
1785
  return node;
1784
- }
1786
+ const prefix = (Array.isArray(resolver.idPrefix) ? resolver.idPrefix[0] : resolver.idPrefix) || "url";
1785
1787
  const rootId = node["@id"] || (Array.isArray(resolver.idPrefix) ? resolver.idPrefix?.[1] : void 0);
1786
- if (resolveAsRoot && rootId) {
1788
+ if (!node["@id"] && resolveAsRoot && rootId) {
1787
1789
  node["@id"] = prefixId(ctx.meta[prefix], rootId);
1790
+ return node;
1788
1791
  }
1789
- if (!node["@id"]) {
1790
- let alias = resolver?.alias;
1791
- if (!alias) {
1792
- const type = asArray(node["@type"])?.[0] || "";
1793
- alias = type.toLowerCase();
1794
- }
1795
- const hashNodeData = {};
1796
- Object.entries(node).forEach(([key, val]) => {
1797
- if (!key.startsWith("_"))
1798
- hashNodeData[key] = val;
1799
- });
1800
- node["@id"] = prefixId(ctx.meta[prefix], `#/schema/${alias}/${hashCode(JSON.stringify(hashNodeData))}`);
1792
+ if (node["@id"]?.startsWith("#/schema/")) {
1793
+ node["@id"] = prefixId(ctx.meta[prefix], node["@id"]);
1794
+ return node;
1801
1795
  }
1796
+ let alias = resolver?.alias;
1797
+ if (!alias) {
1798
+ const type = asArray(node["@type"])?.[0] || "";
1799
+ alias = type.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
1800
+ }
1801
+ const hashNodeData = {};
1802
+ Object.entries(node).forEach(([key, val]) => {
1803
+ if (!key.startsWith("_"))
1804
+ hashNodeData[key] = val;
1805
+ });
1806
+ node["@id"] = prefixId(ctx.meta[prefix], `#/schema/${alias}/${node["@id"] || hashCode(JSON.stringify(hashNodeData))}`);
1802
1807
  return node;
1803
1808
  }
1804
1809
  function resolveRelation(input, ctx, fallbackResolver, options = {}) {
@@ -53,7 +53,7 @@ function prefixId(url, id) {
53
53
  return id;
54
54
  if (!id.startsWith("#"))
55
55
  id = `#${id}`;
56
- return ufo.joinURL(url, id);
56
+ return ufo.withBase(id, url);
57
57
  }
58
58
  function trimLength(val, length) {
59
59
  if (!val)
@@ -295,13 +295,12 @@ const organizationResolver = defineSchemaOrgResolver({
295
295
  resolveRootNode(node, ctx) {
296
296
  const isIdentity = resolveAsGraphKey(node["@id"]) === IdentityId;
297
297
  const webPage = ctx.find(PrimaryWebPageId);
298
- if (node.logo) {
298
+ if (node.logo && isIdentity) {
299
299
  if (!ctx.find("#organization")) {
300
300
  const logoNode = resolveRelation(node.logo, ctx, imageResolver, {
301
301
  root: true,
302
302
  afterResolve(logo) {
303
- if (isIdentity)
304
- logo["@id"] = prefixId(ctx.meta.host, "#logo");
303
+ logo["@id"] = prefixId(ctx.meta.host, "#logo");
305
304
  setIfEmpty(logo, "caption", node.name);
306
305
  }
307
306
  });
@@ -702,6 +701,9 @@ const localBusinessResolver = defineSchemaOrgResolver({
702
701
  node.address = resolveRelation(node.address, ctx, addressResolver);
703
702
  node.openingHoursSpecification = resolveRelation(node.openingHoursSpecification, ctx, openingHoursResolver);
704
703
  node = resolveNode({ ...node }, ctx, organizationResolver);
704
+ return node;
705
+ },
706
+ resolveRootNode(node, ctx) {
705
707
  organizationResolver.resolveRootNode(node, ctx);
706
708
  return node;
707
709
  }
@@ -721,6 +723,10 @@ const foodEstablishmentResolver = defineSchemaOrgResolver({
721
723
  node.starRating = resolveRelation(node.starRating, ctx, ratingResolver);
722
724
  node = resolveNode(node, ctx, localBusinessResolver);
723
725
  return node;
726
+ },
727
+ resolveRootNode(node, ctx) {
728
+ localBusinessResolver.resolveRootNode(node, ctx);
729
+ return node;
724
730
  }
725
731
  });
726
732
 
@@ -1777,30 +1783,29 @@ function resolveNode(node, ctx, resolver) {
1777
1783
  return node;
1778
1784
  }
1779
1785
  function resolveNodeId(node, ctx, resolver, resolveAsRoot = false) {
1780
- const prefix = Array.isArray(resolver.idPrefix) ? resolver.idPrefix[0] : resolver.idPrefix;
1781
- if (!prefix)
1782
- return node;
1783
- if (node["@id"] && !node["@id"].startsWith(ctx.meta.host)) {
1784
- node["@id"] = prefixId(ctx.meta[prefix], node["@id"]);
1786
+ if (node["@id"] && node["@id"].startsWith("http"))
1785
1787
  return node;
1786
- }
1788
+ const prefix = (Array.isArray(resolver.idPrefix) ? resolver.idPrefix[0] : resolver.idPrefix) || "url";
1787
1789
  const rootId = node["@id"] || (Array.isArray(resolver.idPrefix) ? resolver.idPrefix?.[1] : void 0);
1788
- if (resolveAsRoot && rootId) {
1790
+ if (!node["@id"] && resolveAsRoot && rootId) {
1789
1791
  node["@id"] = prefixId(ctx.meta[prefix], rootId);
1792
+ return node;
1790
1793
  }
1791
- if (!node["@id"]) {
1792
- let alias = resolver?.alias;
1793
- if (!alias) {
1794
- const type = asArray(node["@type"])?.[0] || "";
1795
- alias = type.toLowerCase();
1796
- }
1797
- const hashNodeData = {};
1798
- Object.entries(node).forEach(([key, val]) => {
1799
- if (!key.startsWith("_"))
1800
- hashNodeData[key] = val;
1801
- });
1802
- node["@id"] = prefixId(ctx.meta[prefix], `#/schema/${alias}/${shared.hashCode(JSON.stringify(hashNodeData))}`);
1794
+ if (node["@id"]?.startsWith("#/schema/")) {
1795
+ node["@id"] = prefixId(ctx.meta[prefix], node["@id"]);
1796
+ return node;
1803
1797
  }
1798
+ let alias = resolver?.alias;
1799
+ if (!alias) {
1800
+ const type = asArray(node["@type"])?.[0] || "";
1801
+ alias = type.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
1802
+ }
1803
+ const hashNodeData = {};
1804
+ Object.entries(node).forEach(([key, val]) => {
1805
+ if (!key.startsWith("_"))
1806
+ hashNodeData[key] = val;
1807
+ });
1808
+ node["@id"] = prefixId(ctx.meta[prefix], `#/schema/${alias}/${node["@id"] || shared.hashCode(JSON.stringify(hashNodeData))}`);
1804
1809
  return node;
1805
1810
  }
1806
1811
  function resolveRelation(input, ctx, fallbackResolver, options = {}) {
package/dist/vue.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const plugin = require('./shared/schema-org.f81cbd4d.cjs');
3
+ const plugin = require('./shared/schema-org.da628d24.cjs');
4
4
  const vue = require('@unhead/vue');
5
5
  const vue$1 = require('vue');
6
6
  require('@unhead/shared');
package/dist/vue.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { U as UnheadSchemaOrg } from './shared/schema-org.cefa8818.mjs';
2
- export { a1 as PluginSchemaOrg, a2 as SchemaOrgUnheadPlugin } from './shared/schema-org.cefa8818.mjs';
1
+ import { U as UnheadSchemaOrg } from './shared/schema-org.bb03b192.mjs';
2
+ export { a1 as PluginSchemaOrg, a2 as SchemaOrgUnheadPlugin } from './shared/schema-org.bb03b192.mjs';
3
3
  import { injectHead, useHead } from '@unhead/vue';
4
4
  import { defineComponent, ref, computed, unref, h } from 'vue';
5
5
  import '@unhead/shared';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unhead/schema-org",
3
- "version": "1.8.7",
3
+ "version": "1.8.9",
4
4
  "description": "Unhead Schema.org for Simple and Automated Google Rich Results",
5
5
  "author": "Harlan Wilton <harlan@harlanzw.com>",
6
6
  "license": "MIT",
@@ -39,19 +39,19 @@
39
39
  "dist"
40
40
  ],
41
41
  "peerDependencies": {
42
- "unhead": ">=1.8.3",
43
- "@unhead/shared": "1.8.7"
42
+ "unhead": ">=1.8.8",
43
+ "@unhead/shared": "1.8.9"
44
44
  },
45
45
  "dependencies": {
46
46
  "ufo": "^1.3.2"
47
47
  },
48
48
  "devDependencies": {
49
- "unplugin-vue-components": "^0.25.2",
50
- "vue": "^3.3.8",
51
- "@unhead/schema": "1.8.7",
52
- "@unhead/vue": "1.8.7",
53
- "@unhead/shared": "1.8.7",
54
- "unhead": "1.8.7"
49
+ "unplugin-vue-components": "^0.26.0",
50
+ "vue": "^3.3.11",
51
+ "@unhead/schema": "1.8.9",
52
+ "@unhead/shared": "1.8.9",
53
+ "unhead": "1.8.9",
54
+ "@unhead/vue": "1.8.9"
55
55
  },
56
56
  "scripts": {
57
57
  "build": "unbuild .",