@unhead/schema-org 1.9.12 → 1.9.14
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
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const plugin = require('./shared/schema-org.
|
|
3
|
+
const plugin = require('./shared/schema-org.97103adc.cjs');
|
|
4
4
|
const unhead = require('unhead');
|
|
5
|
-
require('@unhead/shared');
|
|
6
5
|
require('ufo');
|
|
7
6
|
|
|
8
7
|
function provideResolver(input, resolver) {
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { U as UnheadSchemaOrg } from './shared/schema-org.
|
|
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.
|
|
1
|
+
import { U as UnheadSchemaOrg } from './shared/schema-org.2da2cd3d.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.2da2cd3d.mjs';
|
|
3
3
|
import { getActiveHead, useHead } from 'unhead';
|
|
4
|
-
import '@unhead/shared';
|
|
5
4
|
import 'ufo';
|
|
6
5
|
|
|
7
6
|
function provideResolver(input, resolver) {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { hashCode, defineHeadPlugin, processTemplateParams } from '@unhead/shared';
|
|
2
1
|
import { hasProtocol, withBase, withoutTrailingSlash, hasTrailingSlash, withTrailingSlash, joinURL } from 'ufo';
|
|
3
2
|
|
|
4
3
|
function defineSchemaOrgResolver(schema) {
|
|
@@ -125,7 +124,8 @@ const monetaryAmountResolver = defineSchemaOrgResolver({
|
|
|
125
124
|
"@type": "MonetaryAmount"
|
|
126
125
|
},
|
|
127
126
|
resolve(node, ctx) {
|
|
128
|
-
|
|
127
|
+
if (typeof node.value !== "number")
|
|
128
|
+
node.value = resolveRelation(node.value, ctx, quantitativeValueResolver);
|
|
129
129
|
return node;
|
|
130
130
|
}
|
|
131
131
|
});
|
|
@@ -1704,6 +1704,55 @@ const softwareAppResolver = defineSchemaOrgResolver({
|
|
|
1704
1704
|
}
|
|
1705
1705
|
});
|
|
1706
1706
|
|
|
1707
|
+
function defineHeadPlugin(plugin) {
|
|
1708
|
+
return plugin;
|
|
1709
|
+
}
|
|
1710
|
+
|
|
1711
|
+
function hashCode(s) {
|
|
1712
|
+
let h = 9;
|
|
1713
|
+
for (let i = 0; i < s.length; )
|
|
1714
|
+
h = Math.imul(h ^ s.charCodeAt(i++), 9 ** 9);
|
|
1715
|
+
return ((h ^ h >>> 9) + 65536).toString(16).substring(1, 8).toLowerCase();
|
|
1716
|
+
}
|
|
1717
|
+
|
|
1718
|
+
const sepSub = "%separator";
|
|
1719
|
+
function processTemplateParams(s, p, sep) {
|
|
1720
|
+
if (typeof s !== "string" || !s.includes("%"))
|
|
1721
|
+
return s;
|
|
1722
|
+
function sub(token) {
|
|
1723
|
+
let val;
|
|
1724
|
+
if (["s", "pageTitle"].includes(token)) {
|
|
1725
|
+
val = p.pageTitle;
|
|
1726
|
+
} else if (token.includes(".")) {
|
|
1727
|
+
val = token.split(".").reduce((acc, key) => acc ? acc[key] || void 0 : void 0, p);
|
|
1728
|
+
} else {
|
|
1729
|
+
val = p[token];
|
|
1730
|
+
}
|
|
1731
|
+
return typeof val !== "undefined" ? (val || "").replace(/"/g, '\\"') : false;
|
|
1732
|
+
}
|
|
1733
|
+
let decoded = s;
|
|
1734
|
+
try {
|
|
1735
|
+
decoded = decodeURI(s);
|
|
1736
|
+
} catch {
|
|
1737
|
+
}
|
|
1738
|
+
const tokens = (decoded.match(/%(\w+\.+\w+)|%(\w+)/g) || []).sort().reverse();
|
|
1739
|
+
tokens.forEach((token) => {
|
|
1740
|
+
const re = sub(token.slice(1));
|
|
1741
|
+
if (typeof re === "string") {
|
|
1742
|
+
s = s.replace(new RegExp(`\\${token}(\\W|$)`, "g"), (_, args) => `${re}${args}`).trim();
|
|
1743
|
+
}
|
|
1744
|
+
});
|
|
1745
|
+
if (s.includes(sepSub)) {
|
|
1746
|
+
if (s.endsWith(sepSub))
|
|
1747
|
+
s = s.slice(0, -sepSub.length).trim();
|
|
1748
|
+
if (s.startsWith(sepSub))
|
|
1749
|
+
s = s.slice(sepSub.length).trim();
|
|
1750
|
+
s = s.replace(new RegExp(`\\${sepSub}\\s*\\${sepSub}`, "g"), sepSub);
|
|
1751
|
+
s = processTemplateParams(s, { separator: sep }, sep);
|
|
1752
|
+
}
|
|
1753
|
+
return s;
|
|
1754
|
+
}
|
|
1755
|
+
|
|
1707
1756
|
function loadResolver(resolver) {
|
|
1708
1757
|
switch (resolver) {
|
|
1709
1758
|
case "address":
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const shared = require('@unhead/shared');
|
|
4
3
|
const ufo = require('ufo');
|
|
5
4
|
|
|
6
5
|
function defineSchemaOrgResolver(schema) {
|
|
@@ -127,7 +126,8 @@ const monetaryAmountResolver = defineSchemaOrgResolver({
|
|
|
127
126
|
"@type": "MonetaryAmount"
|
|
128
127
|
},
|
|
129
128
|
resolve(node, ctx) {
|
|
130
|
-
|
|
129
|
+
if (typeof node.value !== "number")
|
|
130
|
+
node.value = resolveRelation(node.value, ctx, quantitativeValueResolver);
|
|
131
131
|
return node;
|
|
132
132
|
}
|
|
133
133
|
});
|
|
@@ -1706,6 +1706,55 @@ const softwareAppResolver = defineSchemaOrgResolver({
|
|
|
1706
1706
|
}
|
|
1707
1707
|
});
|
|
1708
1708
|
|
|
1709
|
+
function defineHeadPlugin(plugin) {
|
|
1710
|
+
return plugin;
|
|
1711
|
+
}
|
|
1712
|
+
|
|
1713
|
+
function hashCode(s) {
|
|
1714
|
+
let h = 9;
|
|
1715
|
+
for (let i = 0; i < s.length; )
|
|
1716
|
+
h = Math.imul(h ^ s.charCodeAt(i++), 9 ** 9);
|
|
1717
|
+
return ((h ^ h >>> 9) + 65536).toString(16).substring(1, 8).toLowerCase();
|
|
1718
|
+
}
|
|
1719
|
+
|
|
1720
|
+
const sepSub = "%separator";
|
|
1721
|
+
function processTemplateParams(s, p, sep) {
|
|
1722
|
+
if (typeof s !== "string" || !s.includes("%"))
|
|
1723
|
+
return s;
|
|
1724
|
+
function sub(token) {
|
|
1725
|
+
let val;
|
|
1726
|
+
if (["s", "pageTitle"].includes(token)) {
|
|
1727
|
+
val = p.pageTitle;
|
|
1728
|
+
} else if (token.includes(".")) {
|
|
1729
|
+
val = token.split(".").reduce((acc, key) => acc ? acc[key] || void 0 : void 0, p);
|
|
1730
|
+
} else {
|
|
1731
|
+
val = p[token];
|
|
1732
|
+
}
|
|
1733
|
+
return typeof val !== "undefined" ? (val || "").replace(/"/g, '\\"') : false;
|
|
1734
|
+
}
|
|
1735
|
+
let decoded = s;
|
|
1736
|
+
try {
|
|
1737
|
+
decoded = decodeURI(s);
|
|
1738
|
+
} catch {
|
|
1739
|
+
}
|
|
1740
|
+
const tokens = (decoded.match(/%(\w+\.+\w+)|%(\w+)/g) || []).sort().reverse();
|
|
1741
|
+
tokens.forEach((token) => {
|
|
1742
|
+
const re = sub(token.slice(1));
|
|
1743
|
+
if (typeof re === "string") {
|
|
1744
|
+
s = s.replace(new RegExp(`\\${token}(\\W|$)`, "g"), (_, args) => `${re}${args}`).trim();
|
|
1745
|
+
}
|
|
1746
|
+
});
|
|
1747
|
+
if (s.includes(sepSub)) {
|
|
1748
|
+
if (s.endsWith(sepSub))
|
|
1749
|
+
s = s.slice(0, -sepSub.length).trim();
|
|
1750
|
+
if (s.startsWith(sepSub))
|
|
1751
|
+
s = s.slice(sepSub.length).trim();
|
|
1752
|
+
s = s.replace(new RegExp(`\\${sepSub}\\s*\\${sepSub}`, "g"), sepSub);
|
|
1753
|
+
s = processTemplateParams(s, { separator: sep }, sep);
|
|
1754
|
+
}
|
|
1755
|
+
return s;
|
|
1756
|
+
}
|
|
1757
|
+
|
|
1709
1758
|
function loadResolver(resolver) {
|
|
1710
1759
|
switch (resolver) {
|
|
1711
1760
|
case "address":
|
|
@@ -1873,7 +1922,7 @@ function resolveNodeId(node, ctx, resolver, resolveAsRoot = false) {
|
|
|
1873
1922
|
if (!key.startsWith("_"))
|
|
1874
1923
|
hashNodeData[key] = val;
|
|
1875
1924
|
});
|
|
1876
|
-
node["@id"] = prefixId(ctx.meta[prefix], `#/schema/${alias}/${node["@id"] ||
|
|
1925
|
+
node["@id"] = prefixId(ctx.meta[prefix], `#/schema/${alias}/${node["@id"] || hashCode(JSON.stringify(hashNodeData))}`);
|
|
1877
1926
|
return node;
|
|
1878
1927
|
}
|
|
1879
1928
|
function resolveRelation(input, ctx, fallbackResolver, options = {}) {
|
|
@@ -2082,7 +2131,7 @@ function SchemaOrgUnheadPlugin(config, meta, options) {
|
|
|
2082
2131
|
config = resolveMeta({ ...config });
|
|
2083
2132
|
let graph;
|
|
2084
2133
|
let resolvedMeta = {};
|
|
2085
|
-
return
|
|
2134
|
+
return defineHeadPlugin((head) => ({
|
|
2086
2135
|
key: "schema-org",
|
|
2087
2136
|
hooks: {
|
|
2088
2137
|
"entries:resolve": function() {
|
|
@@ -2135,7 +2184,7 @@ function SchemaOrgUnheadPlugin(config, meta, options) {
|
|
|
2135
2184
|
"@graph": graph.resolveGraph({ ...await meta?.() || {}, ...config, ...resolvedMeta })
|
|
2136
2185
|
}, (_, value) => {
|
|
2137
2186
|
if (typeof value !== "object")
|
|
2138
|
-
return
|
|
2187
|
+
return processTemplateParams(value, head._templateParams, head._separator);
|
|
2139
2188
|
return value;
|
|
2140
2189
|
}, minify ? 0 : 2);
|
|
2141
2190
|
delete tag.props.nodes;
|
package/dist/vue.cjs
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const plugin = require('./shared/schema-org.
|
|
3
|
+
const plugin = require('./shared/schema-org.97103adc.cjs');
|
|
4
4
|
const vue = require('@unhead/vue');
|
|
5
5
|
const vue$1 = require('vue');
|
|
6
|
-
require('@unhead/shared');
|
|
7
6
|
require('ufo');
|
|
8
7
|
|
|
9
8
|
const schemaAutoImports = [
|
package/dist/vue.mjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { U as UnheadSchemaOrg } from './shared/schema-org.
|
|
2
|
-
export { a1 as PluginSchemaOrg, a2 as SchemaOrgUnheadPlugin } from './shared/schema-org.
|
|
1
|
+
import { U as UnheadSchemaOrg } from './shared/schema-org.2da2cd3d.mjs';
|
|
2
|
+
export { a1 as PluginSchemaOrg, a2 as SchemaOrgUnheadPlugin } from './shared/schema-org.2da2cd3d.mjs';
|
|
3
3
|
import { injectHead, useHead } from '@unhead/vue';
|
|
4
4
|
import { defineComponent, ref, computed, unref, h } from 'vue';
|
|
5
|
-
import '@unhead/shared';
|
|
6
5
|
import 'ufo';
|
|
7
6
|
|
|
8
7
|
const schemaAutoImports = [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unhead/schema-org",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.14",
|
|
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",
|
|
@@ -38,20 +38,16 @@
|
|
|
38
38
|
"files": [
|
|
39
39
|
"dist"
|
|
40
40
|
],
|
|
41
|
-
"peerDependencies": {
|
|
42
|
-
"unhead": ">=1.9.11",
|
|
43
|
-
"@unhead/shared": "1.9.12"
|
|
44
|
-
},
|
|
45
41
|
"dependencies": {
|
|
46
42
|
"ufo": "^1.5.3"
|
|
47
43
|
},
|
|
48
44
|
"devDependencies": {
|
|
49
45
|
"unplugin-vue-components": "^0.27.0",
|
|
50
|
-
"vue": "^3.4.
|
|
51
|
-
"@unhead/
|
|
52
|
-
"
|
|
53
|
-
"@unhead/
|
|
54
|
-
"unhead": "1.9.
|
|
46
|
+
"vue": "^3.4.29",
|
|
47
|
+
"@unhead/schema": "1.9.14",
|
|
48
|
+
"unhead": "1.9.14",
|
|
49
|
+
"@unhead/shared": "1.9.14",
|
|
50
|
+
"@unhead/vue": "1.9.14"
|
|
55
51
|
},
|
|
56
52
|
"scripts": {
|
|
57
53
|
"build": "unbuild .",
|