@unhead/schema-org 0.5.0 → 1.3.8
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/SchemaOrgUnheadPlugin-dd5249a4.d.ts +1525 -0
- package/dist/index.cjs +142 -1920
- package/dist/index.d.ts +42 -1562
- package/dist/index.mjs +89 -1868
- package/dist/shared/schema-org.02b3dc98.mjs +1970 -0
- package/dist/shared/schema-org.96234618.cjs +2025 -0
- package/dist/vue.cjs +367 -0
- package/dist/vue.d.ts +87 -0
- package/dist/vue.mjs +303 -0
- package/package.json +24 -11
package/dist/index.mjs
CHANGED
|
@@ -1,1895 +1,116 @@
|
|
|
1
|
+
export { H as HowToId, P as PrimaryArticleId, k as PrimaryBookId, m as PrimaryBreadcrumbId, s as PrimaryEventId, V as PrimaryWebPageId, Y as PrimaryWebSiteId, L as ProductId, R as RecipeId, $ as SchemaOrgUnheadPlugin, K 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 howToResolver, y as howToStepDirectionResolver, x as howToStepResolver, A as imageResolver, z as itemListResolver, B as jobPostingResolver, C as listItemResolver, D as localBusinessResolver, E as movieResolver, n as normaliseNodes, F as offerResolver, G as openingHoursResolver, I as organizationResolver, J as personResolver, u as placeResolver, M as productResolver, N as questionResolver, O as ratingResolver, X as readActionResolver, Q as recipeResolver, r as resolveMeta, b as resolveNode, e as resolveNodeId, f as resolveRelation, T as reviewResolver, _ as searchActionResolver, S as softwareAppResolver, U as videoResolver, v as virtualLocationResolver, W as webPageResolver, Z as webSiteResolver } from './shared/schema-org.02b3dc98.mjs';
|
|
1
2
|
import { useHead } from 'unhead';
|
|
3
|
+
import 'ufo';
|
|
4
|
+
import '@unhead/shared';
|
|
2
5
|
|
|
3
|
-
function
|
|
4
|
-
|
|
6
|
+
function provideResolver(input, resolver) {
|
|
7
|
+
if (!input)
|
|
8
|
+
input = {};
|
|
9
|
+
input._resolver = resolver;
|
|
10
|
+
return input;
|
|
5
11
|
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const PROTOCOL_REGEX = /^\w{2,}:([/\\]{2})?/;
|
|
9
|
-
const PROTOCOL_RELATIVE_REGEX = /^[/\\]{2}[^/\\]+/;
|
|
10
|
-
function hasProtocol(inputString, opts = {}) {
|
|
11
|
-
if (typeof opts === "boolean") {
|
|
12
|
-
opts = { acceptRelative: opts };
|
|
13
|
-
}
|
|
14
|
-
if (opts.strict) {
|
|
15
|
-
return PROTOCOL_STRICT_REGEX.test(inputString);
|
|
16
|
-
}
|
|
17
|
-
return PROTOCOL_REGEX.test(inputString) || (opts.acceptRelative ? PROTOCOL_RELATIVE_REGEX.test(inputString) : false);
|
|
12
|
+
function defineAddress(input) {
|
|
13
|
+
return provideResolver(input, "address");
|
|
18
14
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (!queryParameters) {
|
|
22
|
-
return input.endsWith("/");
|
|
23
|
-
}
|
|
24
|
-
return TRAILING_SLASH_RE.test(input);
|
|
15
|
+
function defineAggregateOffer(input) {
|
|
16
|
+
return provideResolver(input, "aggregateOffer");
|
|
25
17
|
}
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
return (hasTrailingSlash(input) ? input.slice(0, -1) : input) || "/";
|
|
29
|
-
}
|
|
30
|
-
if (!hasTrailingSlash(input, true)) {
|
|
31
|
-
return input || "/";
|
|
32
|
-
}
|
|
33
|
-
const [s0, ...s] = input.split("?");
|
|
34
|
-
return (s0.slice(0, -1) || "/") + (s.length > 0 ? `?${s.join("?")}` : "");
|
|
18
|
+
function defineAggregateRating(input) {
|
|
19
|
+
return provideResolver(input, "aggregateRating");
|
|
35
20
|
}
|
|
36
|
-
function
|
|
37
|
-
|
|
38
|
-
return input.endsWith("/") ? input : input + "/";
|
|
39
|
-
}
|
|
40
|
-
if (hasTrailingSlash(input, true)) {
|
|
41
|
-
return input || "/";
|
|
42
|
-
}
|
|
43
|
-
const [s0, ...s] = input.split("?");
|
|
44
|
-
return s0 + "/" + (s.length > 0 ? `?${s.join("?")}` : "");
|
|
21
|
+
function defineArticle(input) {
|
|
22
|
+
return provideResolver(input, "article");
|
|
45
23
|
}
|
|
46
|
-
function
|
|
47
|
-
return input
|
|
24
|
+
function defineBreadcrumb(input) {
|
|
25
|
+
return provideResolver(input, "breadcrumb");
|
|
48
26
|
}
|
|
49
|
-
function
|
|
50
|
-
return (
|
|
27
|
+
function defineComment(input) {
|
|
28
|
+
return provideResolver(input, "comment");
|
|
51
29
|
}
|
|
52
|
-
function
|
|
53
|
-
|
|
54
|
-
return input;
|
|
55
|
-
}
|
|
56
|
-
const _base = withoutTrailingSlash(base);
|
|
57
|
-
if (input.startsWith(_base)) {
|
|
58
|
-
return input;
|
|
59
|
-
}
|
|
60
|
-
return joinURL(_base, input);
|
|
30
|
+
function defineEvent(input) {
|
|
31
|
+
return provideResolver(input, "event");
|
|
61
32
|
}
|
|
62
|
-
function
|
|
63
|
-
return
|
|
33
|
+
function defineVirtualLocation(input) {
|
|
34
|
+
return provideResolver(input, "virtualLocation");
|
|
64
35
|
}
|
|
65
|
-
function
|
|
66
|
-
return
|
|
36
|
+
function definePlace(input) {
|
|
37
|
+
return provideResolver(input, "place");
|
|
67
38
|
}
|
|
68
|
-
function
|
|
69
|
-
|
|
70
|
-
for (const index of input.filter((url2) => isNonEmptyURL(url2))) {
|
|
71
|
-
url = url ? withTrailingSlash(url) + withoutLeadingSlash(index) : index;
|
|
72
|
-
}
|
|
73
|
-
return url;
|
|
39
|
+
function defineHowTo(input) {
|
|
40
|
+
return provideResolver(input, "howTo");
|
|
74
41
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
"@id": typeof node !== "string" ? node["@id"] : node
|
|
78
|
-
});
|
|
79
|
-
const resolvableDateToDate = (val) => {
|
|
80
|
-
try {
|
|
81
|
-
const date = val instanceof Date ? val : new Date(Date.parse(val));
|
|
82
|
-
return `${date.getFullYear()}-${date.getMonth()}-${date.getDate()}`;
|
|
83
|
-
} catch (e) {
|
|
84
|
-
}
|
|
85
|
-
return typeof val === "string" ? val : val.toString();
|
|
86
|
-
};
|
|
87
|
-
const resolvableDateToIso = (val) => {
|
|
88
|
-
if (!val)
|
|
89
|
-
return val;
|
|
90
|
-
try {
|
|
91
|
-
if (val instanceof Date)
|
|
92
|
-
return val.toISOString();
|
|
93
|
-
else
|
|
94
|
-
return new Date(Date.parse(val)).toISOString();
|
|
95
|
-
} catch (e) {
|
|
96
|
-
}
|
|
97
|
-
return typeof val === "string" ? val : val.toString();
|
|
98
|
-
};
|
|
99
|
-
const IdentityId = "#identity";
|
|
100
|
-
const setIfEmpty = (node, field, value) => {
|
|
101
|
-
if (!node?.[field] && value)
|
|
102
|
-
node[field] = value;
|
|
103
|
-
};
|
|
104
|
-
const asArray = (input) => Array.isArray(input) ? input : [input];
|
|
105
|
-
const dedupeMerge = (node, field, value) => {
|
|
106
|
-
const dedupeMerge2 = [];
|
|
107
|
-
const input = asArray(node[field]);
|
|
108
|
-
dedupeMerge2.push(...input);
|
|
109
|
-
const data = new Set(dedupeMerge2);
|
|
110
|
-
data.add(value);
|
|
111
|
-
node[field] = [...data.values()].filter(Boolean);
|
|
112
|
-
};
|
|
113
|
-
const prefixId = (url, id) => {
|
|
114
|
-
if (hasProtocol(id))
|
|
115
|
-
return url;
|
|
116
|
-
if (!id.startsWith("#"))
|
|
117
|
-
id = `#${id}`;
|
|
118
|
-
return joinURL(url, id);
|
|
119
|
-
};
|
|
120
|
-
const trimLength = (val, length) => {
|
|
121
|
-
if (!val)
|
|
122
|
-
return val;
|
|
123
|
-
if (val.length > length) {
|
|
124
|
-
const trimmedString = val.substring(0, length);
|
|
125
|
-
return trimmedString.substring(0, Math.min(trimmedString.length, trimmedString.lastIndexOf(" ")));
|
|
126
|
-
}
|
|
127
|
-
return val;
|
|
128
|
-
};
|
|
129
|
-
const resolveDefaultType = (node, defaultType) => {
|
|
130
|
-
const val = node["@type"];
|
|
131
|
-
if (val === defaultType)
|
|
132
|
-
return;
|
|
133
|
-
const types = /* @__PURE__ */ new Set([
|
|
134
|
-
...asArray(defaultType),
|
|
135
|
-
...asArray(val)
|
|
136
|
-
]);
|
|
137
|
-
node["@type"] = types.size === 1 ? val : [...types.values()];
|
|
138
|
-
};
|
|
139
|
-
const resolveWithBase = (base, urlOrPath) => {
|
|
140
|
-
if (!urlOrPath || hasProtocol(urlOrPath) || !urlOrPath.startsWith("/") && !urlOrPath.startsWith("#"))
|
|
141
|
-
return urlOrPath;
|
|
142
|
-
return withBase(urlOrPath, base);
|
|
143
|
-
};
|
|
144
|
-
const resolveAsGraphKey = (key) => {
|
|
145
|
-
if (!key)
|
|
146
|
-
return key;
|
|
147
|
-
return key.substring(key.lastIndexOf("#"));
|
|
148
|
-
};
|
|
149
|
-
const stripEmptyProperties = (obj) => {
|
|
150
|
-
Object.keys(obj).forEach((k) => {
|
|
151
|
-
if (obj[k] && typeof obj[k] === "object") {
|
|
152
|
-
if (obj[k].__v_isReadonly || obj[k].__v_isRef)
|
|
153
|
-
return;
|
|
154
|
-
stripEmptyProperties(obj[k]);
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
if (obj[k] === "" || obj[k] === null || typeof obj[k] === "undefined")
|
|
158
|
-
delete obj[k];
|
|
159
|
-
});
|
|
160
|
-
return obj;
|
|
161
|
-
};
|
|
162
|
-
function hashCode(s) {
|
|
163
|
-
let h = 9;
|
|
164
|
-
for (let i = 0; i < s.length; )
|
|
165
|
-
h = Math.imul(h ^ s.charCodeAt(i++), 9 ** 9);
|
|
166
|
-
return ((h ^ h >>> 9) + 65536).toString(16).substring(1, 8).toLowerCase();
|
|
42
|
+
function defineHowToStep(input) {
|
|
43
|
+
return provideResolver(input, "howToStep");
|
|
167
44
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
cast(node) {
|
|
171
|
-
if (typeof node === "number" || typeof node === "string") {
|
|
172
|
-
return {
|
|
173
|
-
price: node
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
return node;
|
|
177
|
-
},
|
|
178
|
-
defaults: {
|
|
179
|
-
"@type": "Offer",
|
|
180
|
-
"availability": "InStock"
|
|
181
|
-
},
|
|
182
|
-
resolve(node, ctx) {
|
|
183
|
-
setIfEmpty(node, "priceCurrency", ctx.meta.currency);
|
|
184
|
-
setIfEmpty(node, "priceValidUntil", new Date(Date.UTC((/* @__PURE__ */ new Date()).getFullYear() + 1, 12, -1, 0, 0, 0)));
|
|
185
|
-
if (node.url)
|
|
186
|
-
resolveWithBase(ctx.meta.host, node.url);
|
|
187
|
-
if (node.availability)
|
|
188
|
-
node.availability = withBase(node.availability, "https://schema.org/");
|
|
189
|
-
if (node.priceValidUntil)
|
|
190
|
-
node.priceValidUntil = resolvableDateToIso(node.priceValidUntil);
|
|
191
|
-
return node;
|
|
192
|
-
}
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
const aggregateOfferResolver = defineSchemaOrgResolver({
|
|
196
|
-
defaults: {
|
|
197
|
-
"@type": "AggregateOffer"
|
|
198
|
-
},
|
|
199
|
-
inheritMeta: [
|
|
200
|
-
{ meta: "currency", key: "priceCurrency" }
|
|
201
|
-
],
|
|
202
|
-
resolve(node, ctx) {
|
|
203
|
-
node.offers = resolveRelation(node.offers, ctx, offerResolver);
|
|
204
|
-
if (node.offers)
|
|
205
|
-
setIfEmpty(node, "offerCount", asArray(node.offers).length);
|
|
206
|
-
return node;
|
|
207
|
-
}
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
const aggregateRatingResolver = defineSchemaOrgResolver({
|
|
211
|
-
defaults: {
|
|
212
|
-
"@type": "AggregateRating"
|
|
213
|
-
}
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
const searchActionResolver = defineSchemaOrgResolver({
|
|
217
|
-
defaults: {
|
|
218
|
-
"@type": "SearchAction",
|
|
219
|
-
"target": {
|
|
220
|
-
"@type": "EntryPoint"
|
|
221
|
-
},
|
|
222
|
-
"query-input": {
|
|
223
|
-
"@type": "PropertyValueSpecification",
|
|
224
|
-
"valueRequired": true,
|
|
225
|
-
"valueName": "search_term_string"
|
|
226
|
-
}
|
|
227
|
-
},
|
|
228
|
-
resolve(node, ctx) {
|
|
229
|
-
if (typeof node.target === "string") {
|
|
230
|
-
node.target = {
|
|
231
|
-
"@type": "EntryPoint",
|
|
232
|
-
"urlTemplate": resolveWithBase(ctx.meta.host, node.target)
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
|
-
return node;
|
|
236
|
-
}
|
|
237
|
-
});
|
|
238
|
-
|
|
239
|
-
const PrimaryWebSiteId = "#website";
|
|
240
|
-
const webSiteResolver = defineSchemaOrgResolver({
|
|
241
|
-
defaults: {
|
|
242
|
-
"@type": "WebSite"
|
|
243
|
-
},
|
|
244
|
-
inheritMeta: [
|
|
245
|
-
"inLanguage",
|
|
246
|
-
{ meta: "host", key: "url" }
|
|
247
|
-
],
|
|
248
|
-
idPrefix: ["host", PrimaryWebSiteId],
|
|
249
|
-
resolve(node, ctx) {
|
|
250
|
-
node.potentialAction = resolveRelation(node.potentialAction, ctx, searchActionResolver, {
|
|
251
|
-
array: true
|
|
252
|
-
});
|
|
253
|
-
node.publisher = resolveRelation(node.publisher, ctx);
|
|
254
|
-
return node;
|
|
255
|
-
},
|
|
256
|
-
resolveRootNode(node, { find }) {
|
|
257
|
-
if (resolveAsGraphKey(node["@id"]) === PrimaryWebSiteId) {
|
|
258
|
-
const identity = find(IdentityId);
|
|
259
|
-
if (identity)
|
|
260
|
-
setIfEmpty(node, "publisher", idReference(identity));
|
|
261
|
-
const webPage = find(PrimaryWebPageId);
|
|
262
|
-
if (webPage)
|
|
263
|
-
setIfEmpty(webPage, "isPartOf", idReference(node));
|
|
264
|
-
}
|
|
265
|
-
return node;
|
|
266
|
-
}
|
|
267
|
-
});
|
|
268
|
-
|
|
269
|
-
const listItemResolver = defineSchemaOrgResolver({
|
|
270
|
-
cast(node) {
|
|
271
|
-
if (typeof node === "string") {
|
|
272
|
-
node = {
|
|
273
|
-
name: node
|
|
274
|
-
};
|
|
275
|
-
}
|
|
276
|
-
return node;
|
|
277
|
-
},
|
|
278
|
-
defaults: {
|
|
279
|
-
"@type": "ListItem"
|
|
280
|
-
},
|
|
281
|
-
resolve(node, ctx) {
|
|
282
|
-
if (typeof node.item === "string")
|
|
283
|
-
node.item = resolveWithBase(ctx.meta.host, node.item);
|
|
284
|
-
else if (typeof node.item === "object")
|
|
285
|
-
node.item = resolveRelation(node.item, ctx);
|
|
286
|
-
return node;
|
|
287
|
-
}
|
|
288
|
-
});
|
|
289
|
-
|
|
290
|
-
const PrimaryBreadcrumbId = "#breadcrumb";
|
|
291
|
-
const breadcrumbResolver = defineSchemaOrgResolver({
|
|
292
|
-
defaults: {
|
|
293
|
-
"@type": "BreadcrumbList"
|
|
294
|
-
},
|
|
295
|
-
idPrefix: ["url", PrimaryBreadcrumbId],
|
|
296
|
-
resolve(breadcrumb, ctx) {
|
|
297
|
-
if (breadcrumb.itemListElement) {
|
|
298
|
-
let index = 1;
|
|
299
|
-
breadcrumb.itemListElement = resolveRelation(breadcrumb.itemListElement, ctx, listItemResolver, {
|
|
300
|
-
array: true,
|
|
301
|
-
afterResolve(node) {
|
|
302
|
-
setIfEmpty(node, "position", index++);
|
|
303
|
-
}
|
|
304
|
-
});
|
|
305
|
-
}
|
|
306
|
-
return breadcrumb;
|
|
307
|
-
},
|
|
308
|
-
resolveRootNode(node, { find }) {
|
|
309
|
-
const webPage = find(PrimaryWebPageId);
|
|
310
|
-
if (webPage)
|
|
311
|
-
setIfEmpty(webPage, "breadcrumb", idReference(node));
|
|
312
|
-
}
|
|
313
|
-
});
|
|
314
|
-
|
|
315
|
-
const imageResolver = defineSchemaOrgResolver({
|
|
316
|
-
alias: "image",
|
|
317
|
-
cast(input) {
|
|
318
|
-
if (typeof input === "string") {
|
|
319
|
-
input = {
|
|
320
|
-
url: input
|
|
321
|
-
};
|
|
322
|
-
}
|
|
323
|
-
return input;
|
|
324
|
-
},
|
|
325
|
-
defaults: {
|
|
326
|
-
"@type": "ImageObject"
|
|
327
|
-
},
|
|
328
|
-
inheritMeta: [
|
|
329
|
-
// @todo possibly only do if there's a caption
|
|
330
|
-
"inLanguage"
|
|
331
|
-
],
|
|
332
|
-
idPrefix: "host",
|
|
333
|
-
resolve(image, { meta }) {
|
|
334
|
-
image.url = resolveWithBase(meta.host, image.url);
|
|
335
|
-
setIfEmpty(image, "contentUrl", image.url);
|
|
336
|
-
if (image.height && !image.width)
|
|
337
|
-
delete image.height;
|
|
338
|
-
if (image.width && !image.height)
|
|
339
|
-
delete image.width;
|
|
340
|
-
return image;
|
|
341
|
-
}
|
|
342
|
-
});
|
|
343
|
-
|
|
344
|
-
const addressResolver = defineSchemaOrgResolver({
|
|
345
|
-
defaults: {
|
|
346
|
-
"@type": "PostalAddress"
|
|
347
|
-
}
|
|
348
|
-
});
|
|
349
|
-
|
|
350
|
-
const organizationResolver = defineSchemaOrgResolver({
|
|
351
|
-
defaults: {
|
|
352
|
-
"@type": "Organization"
|
|
353
|
-
},
|
|
354
|
-
idPrefix: ["host", IdentityId],
|
|
355
|
-
inheritMeta: [
|
|
356
|
-
{ meta: "host", key: "url" }
|
|
357
|
-
],
|
|
358
|
-
resolve(node, ctx) {
|
|
359
|
-
resolveDefaultType(node, "Organization");
|
|
360
|
-
node.address = resolveRelation(node.address, ctx, addressResolver);
|
|
361
|
-
return node;
|
|
362
|
-
},
|
|
363
|
-
resolveRootNode(node, ctx) {
|
|
364
|
-
const isIdentity = resolveAsGraphKey(node["@id"]) === IdentityId;
|
|
365
|
-
const webPage = ctx.find(PrimaryWebPageId);
|
|
366
|
-
if (node.logo) {
|
|
367
|
-
node.logo = resolveRelation(node.logo, ctx, imageResolver, {
|
|
368
|
-
root: true,
|
|
369
|
-
afterResolve(logo) {
|
|
370
|
-
if (isIdentity)
|
|
371
|
-
logo["@id"] = prefixId(ctx.meta.host, "#logo");
|
|
372
|
-
setIfEmpty(logo, "caption", node.name);
|
|
373
|
-
}
|
|
374
|
-
});
|
|
375
|
-
if (webPage)
|
|
376
|
-
setIfEmpty(webPage, "primaryImageOfPage", idReference(node.logo));
|
|
377
|
-
}
|
|
378
|
-
if (isIdentity && webPage)
|
|
379
|
-
setIfEmpty(webPage, "about", idReference(node));
|
|
380
|
-
const webSite = ctx.find(PrimaryWebSiteId);
|
|
381
|
-
if (webSite)
|
|
382
|
-
setIfEmpty(webSite, "publisher", idReference(node));
|
|
383
|
-
}
|
|
384
|
-
});
|
|
385
|
-
|
|
386
|
-
const personResolver = defineSchemaOrgResolver({
|
|
387
|
-
cast(node) {
|
|
388
|
-
if (typeof node === "string") {
|
|
389
|
-
return {
|
|
390
|
-
name: node
|
|
391
|
-
};
|
|
392
|
-
}
|
|
393
|
-
return node;
|
|
394
|
-
},
|
|
395
|
-
defaults: {
|
|
396
|
-
"@type": "Person"
|
|
397
|
-
},
|
|
398
|
-
idPrefix: ["host", IdentityId],
|
|
399
|
-
resolveRootNode(node, { find, meta }) {
|
|
400
|
-
if (resolveAsGraphKey(node["@id"]) === IdentityId) {
|
|
401
|
-
setIfEmpty(node, "url", meta.host);
|
|
402
|
-
const webPage = find(PrimaryWebPageId);
|
|
403
|
-
if (webPage)
|
|
404
|
-
setIfEmpty(webPage, "about", idReference(node));
|
|
405
|
-
const webSite = find(PrimaryWebSiteId);
|
|
406
|
-
if (webSite)
|
|
407
|
-
setIfEmpty(webSite, "publisher", idReference(node));
|
|
408
|
-
}
|
|
409
|
-
const article = find(PrimaryArticleId);
|
|
410
|
-
if (article)
|
|
411
|
-
setIfEmpty(article, "author", idReference(node));
|
|
412
|
-
}
|
|
413
|
-
});
|
|
414
|
-
|
|
415
|
-
const readActionResolver = defineSchemaOrgResolver({
|
|
416
|
-
defaults: {
|
|
417
|
-
"@type": "ReadAction"
|
|
418
|
-
},
|
|
419
|
-
resolve(node, ctx) {
|
|
420
|
-
if (!node.target.includes(ctx.meta.url))
|
|
421
|
-
node.target.unshift(ctx.meta.url);
|
|
422
|
-
return node;
|
|
423
|
-
}
|
|
424
|
-
});
|
|
425
|
-
|
|
426
|
-
const PrimaryWebPageId = "#webpage";
|
|
427
|
-
const webPageResolver = defineSchemaOrgResolver({
|
|
428
|
-
defaults({ meta }) {
|
|
429
|
-
const endPath = withoutTrailingSlash(meta.url.substring(meta.url.lastIndexOf("/") + 1));
|
|
430
|
-
let type = "WebPage";
|
|
431
|
-
switch (endPath) {
|
|
432
|
-
case "about":
|
|
433
|
-
case "about-us":
|
|
434
|
-
type = "AboutPage";
|
|
435
|
-
break;
|
|
436
|
-
case "search":
|
|
437
|
-
type = "SearchResultsPage";
|
|
438
|
-
break;
|
|
439
|
-
case "checkout":
|
|
440
|
-
type = "CheckoutPage";
|
|
441
|
-
break;
|
|
442
|
-
case "contact":
|
|
443
|
-
case "get-in-touch":
|
|
444
|
-
case "contact-us":
|
|
445
|
-
type = "ContactPage";
|
|
446
|
-
break;
|
|
447
|
-
case "faq":
|
|
448
|
-
type = "FAQPage";
|
|
449
|
-
break;
|
|
450
|
-
}
|
|
451
|
-
const defaults = {
|
|
452
|
-
"@type": type
|
|
453
|
-
};
|
|
454
|
-
return defaults;
|
|
455
|
-
},
|
|
456
|
-
idPrefix: ["url", PrimaryWebPageId],
|
|
457
|
-
inheritMeta: [
|
|
458
|
-
{ meta: "title", key: "name" },
|
|
459
|
-
"description",
|
|
460
|
-
"datePublished",
|
|
461
|
-
"dateModified",
|
|
462
|
-
"url"
|
|
463
|
-
],
|
|
464
|
-
resolve(node, ctx) {
|
|
465
|
-
node.dateModified = resolvableDateToIso(node.dateModified);
|
|
466
|
-
node.datePublished = resolvableDateToIso(node.datePublished);
|
|
467
|
-
resolveDefaultType(node, "WebPage");
|
|
468
|
-
node.about = resolveRelation(node.about, ctx, organizationResolver);
|
|
469
|
-
node.breadcrumb = resolveRelation(node.breadcrumb, ctx, breadcrumbResolver);
|
|
470
|
-
node.author = resolveRelation(node.author, ctx, personResolver);
|
|
471
|
-
node.primaryImageOfPage = resolveRelation(node.primaryImageOfPage, ctx, imageResolver);
|
|
472
|
-
node.potentialAction = resolveRelation(node.potentialAction, ctx, readActionResolver);
|
|
473
|
-
if (node["@type"] === "WebPage") {
|
|
474
|
-
setIfEmpty(node, "potentialAction", [
|
|
475
|
-
{
|
|
476
|
-
"@type": "ReadAction",
|
|
477
|
-
"target": [ctx.meta.url]
|
|
478
|
-
}
|
|
479
|
-
]);
|
|
480
|
-
}
|
|
481
|
-
return node;
|
|
482
|
-
},
|
|
483
|
-
resolveRootNode(webPage, { find, meta }) {
|
|
484
|
-
const identity = find(IdentityId);
|
|
485
|
-
const webSite = find(PrimaryWebSiteId);
|
|
486
|
-
const logo = find("#logo");
|
|
487
|
-
if (identity && meta.url === meta.host)
|
|
488
|
-
setIfEmpty(webPage, "about", idReference(identity));
|
|
489
|
-
if (logo)
|
|
490
|
-
setIfEmpty(webPage, "primaryImageOfPage", idReference(logo));
|
|
491
|
-
if (webSite)
|
|
492
|
-
setIfEmpty(webPage, "isPartOf", idReference(webSite));
|
|
493
|
-
const breadcrumb = find(PrimaryBreadcrumbId);
|
|
494
|
-
if (breadcrumb)
|
|
495
|
-
setIfEmpty(webPage, "breadcrumb", idReference(breadcrumb));
|
|
496
|
-
return webPage;
|
|
497
|
-
}
|
|
498
|
-
});
|
|
499
|
-
|
|
500
|
-
const PrimaryArticleId = "#article";
|
|
501
|
-
const articleResolver = defineSchemaOrgResolver({
|
|
502
|
-
defaults: {
|
|
503
|
-
"@type": "Article"
|
|
504
|
-
},
|
|
505
|
-
inheritMeta: [
|
|
506
|
-
"inLanguage",
|
|
507
|
-
"description",
|
|
508
|
-
"image",
|
|
509
|
-
"dateModified",
|
|
510
|
-
"datePublished",
|
|
511
|
-
{ meta: "title", key: "headline" }
|
|
512
|
-
],
|
|
513
|
-
idPrefix: ["url", PrimaryArticleId],
|
|
514
|
-
resolve(node, ctx) {
|
|
515
|
-
node.author = resolveRelation(node.author, ctx, personResolver, {
|
|
516
|
-
root: true
|
|
517
|
-
});
|
|
518
|
-
node.publisher = resolveRelation(node.publisher, ctx);
|
|
519
|
-
node.dateModified = resolvableDateToIso(node.dateModified);
|
|
520
|
-
node.datePublished = resolvableDateToIso(node.datePublished);
|
|
521
|
-
resolveDefaultType(node, "Article");
|
|
522
|
-
node.headline = trimLength(node.headline, 110);
|
|
523
|
-
return node;
|
|
524
|
-
},
|
|
525
|
-
resolveRootNode(node, { find, meta }) {
|
|
526
|
-
const webPage = find(PrimaryWebPageId);
|
|
527
|
-
const identity = find(IdentityId);
|
|
528
|
-
if (node.image && !node.thumbnailUrl) {
|
|
529
|
-
const firstImage = asArray(node.image)[0];
|
|
530
|
-
if (typeof firstImage === "string")
|
|
531
|
-
setIfEmpty(node, "thumbnailUrl", resolveWithBase(meta.host, firstImage));
|
|
532
|
-
else if (firstImage?.["@id"])
|
|
533
|
-
setIfEmpty(node, "thumbnailUrl", find(firstImage["@id"])?.url);
|
|
534
|
-
}
|
|
535
|
-
if (identity) {
|
|
536
|
-
setIfEmpty(node, "publisher", idReference(identity));
|
|
537
|
-
setIfEmpty(node, "author", idReference(identity));
|
|
538
|
-
}
|
|
539
|
-
if (webPage) {
|
|
540
|
-
setIfEmpty(node, "isPartOf", idReference(webPage));
|
|
541
|
-
setIfEmpty(node, "mainEntityOfPage", idReference(webPage));
|
|
542
|
-
setIfEmpty(webPage, "potentialAction", [
|
|
543
|
-
{
|
|
544
|
-
"@type": "ReadAction",
|
|
545
|
-
"target": [meta.url]
|
|
546
|
-
}
|
|
547
|
-
]);
|
|
548
|
-
setIfEmpty(webPage, "dateModified", node.dateModified);
|
|
549
|
-
setIfEmpty(webPage, "datePublished", node.datePublished);
|
|
550
|
-
}
|
|
551
|
-
return node;
|
|
552
|
-
}
|
|
553
|
-
});
|
|
554
|
-
|
|
555
|
-
const bookEditionResolver = defineSchemaOrgResolver({
|
|
556
|
-
defaults: {
|
|
557
|
-
"@type": "Book"
|
|
558
|
-
},
|
|
559
|
-
inheritMeta: [
|
|
560
|
-
"inLanguage"
|
|
561
|
-
],
|
|
562
|
-
resolve(node, ctx) {
|
|
563
|
-
if (node.bookFormat)
|
|
564
|
-
node.bookFormat = withBase(node.bookFormat, "https://schema.org/");
|
|
565
|
-
if (node.datePublished)
|
|
566
|
-
node.datePublished = resolvableDateToDate(node.datePublished);
|
|
567
|
-
node.author = resolveRelation(node.author, ctx);
|
|
568
|
-
return node;
|
|
569
|
-
},
|
|
570
|
-
resolveRootNode(node, { find }) {
|
|
571
|
-
const identity = find(IdentityId);
|
|
572
|
-
if (identity)
|
|
573
|
-
setIfEmpty(node, "provider", idReference(identity));
|
|
574
|
-
return node;
|
|
575
|
-
}
|
|
576
|
-
});
|
|
577
|
-
const PrimaryBookId = "#book";
|
|
578
|
-
const bookResolver = defineSchemaOrgResolver({
|
|
579
|
-
defaults: {
|
|
580
|
-
"@type": "Book"
|
|
581
|
-
},
|
|
582
|
-
inheritMeta: [
|
|
583
|
-
"description",
|
|
584
|
-
"url",
|
|
585
|
-
{ meta: "title", key: "name" }
|
|
586
|
-
],
|
|
587
|
-
idPrefix: ["url", PrimaryBookId],
|
|
588
|
-
resolve(node, ctx) {
|
|
589
|
-
node.workExample = resolveRelation(node.workExample, ctx, bookEditionResolver);
|
|
590
|
-
node.author = resolveRelation(node.author, ctx);
|
|
591
|
-
if (node.url)
|
|
592
|
-
withBase(node.url, ctx.meta.host);
|
|
593
|
-
return node;
|
|
594
|
-
},
|
|
595
|
-
resolveRootNode(node, { find }) {
|
|
596
|
-
const identity = find(IdentityId);
|
|
597
|
-
if (identity)
|
|
598
|
-
setIfEmpty(node, "author", idReference(identity));
|
|
599
|
-
return node;
|
|
600
|
-
}
|
|
601
|
-
});
|
|
602
|
-
|
|
603
|
-
const commentResolver = defineSchemaOrgResolver({
|
|
604
|
-
defaults: {
|
|
605
|
-
"@type": "Comment"
|
|
606
|
-
},
|
|
607
|
-
idPrefix: "url",
|
|
608
|
-
resolve(node, ctx) {
|
|
609
|
-
node.author = resolveRelation(node.author, ctx, personResolver, {
|
|
610
|
-
root: true
|
|
611
|
-
});
|
|
612
|
-
return node;
|
|
613
|
-
},
|
|
614
|
-
resolveRootNode(node, { find }) {
|
|
615
|
-
const article = find(PrimaryArticleId);
|
|
616
|
-
if (article)
|
|
617
|
-
setIfEmpty(node, "about", idReference(article));
|
|
618
|
-
}
|
|
619
|
-
});
|
|
620
|
-
|
|
621
|
-
const courseResolver = defineSchemaOrgResolver({
|
|
622
|
-
defaults: {
|
|
623
|
-
"@type": "Course"
|
|
624
|
-
},
|
|
625
|
-
resolve(node, ctx) {
|
|
626
|
-
node.provider = resolveRelation(node.provider, ctx, organizationResolver, {
|
|
627
|
-
root: true
|
|
628
|
-
});
|
|
629
|
-
return node;
|
|
630
|
-
},
|
|
631
|
-
resolveRootNode(node, { find }) {
|
|
632
|
-
const identity = find(IdentityId);
|
|
633
|
-
if (identity)
|
|
634
|
-
setIfEmpty(node, "provider", idReference(identity));
|
|
635
|
-
return node;
|
|
636
|
-
}
|
|
637
|
-
});
|
|
638
|
-
|
|
639
|
-
const placeResolver = defineSchemaOrgResolver({
|
|
640
|
-
defaults: {
|
|
641
|
-
"@type": "Place"
|
|
642
|
-
},
|
|
643
|
-
resolve(node, ctx) {
|
|
644
|
-
if (typeof node.address !== "string")
|
|
645
|
-
node.address = resolveRelation(node.address, ctx, addressResolver);
|
|
646
|
-
return node;
|
|
647
|
-
}
|
|
648
|
-
});
|
|
649
|
-
|
|
650
|
-
const virtualLocationResolver = defineSchemaOrgResolver({
|
|
651
|
-
cast(node) {
|
|
652
|
-
if (typeof node === "string") {
|
|
653
|
-
return {
|
|
654
|
-
url: node
|
|
655
|
-
};
|
|
656
|
-
}
|
|
657
|
-
return node;
|
|
658
|
-
},
|
|
659
|
-
defaults: {
|
|
660
|
-
"@type": "VirtualLocation"
|
|
661
|
-
}
|
|
662
|
-
});
|
|
663
|
-
|
|
664
|
-
const PrimaryEventId = "#event";
|
|
665
|
-
const eventResolver = defineSchemaOrgResolver({
|
|
666
|
-
defaults: {
|
|
667
|
-
"@type": "Event"
|
|
668
|
-
},
|
|
669
|
-
inheritMeta: [
|
|
670
|
-
"inLanguage",
|
|
671
|
-
"description",
|
|
672
|
-
"image",
|
|
673
|
-
{ meta: "title", key: "name" }
|
|
674
|
-
],
|
|
675
|
-
idPrefix: ["url", PrimaryEventId],
|
|
676
|
-
resolve(node, ctx) {
|
|
677
|
-
if (node.location) {
|
|
678
|
-
const isVirtual = node.location === "string" || node.location?.url !== "undefined";
|
|
679
|
-
node.location = resolveRelation(node.location, ctx, isVirtual ? virtualLocationResolver : placeResolver);
|
|
680
|
-
}
|
|
681
|
-
node.performer = resolveRelation(node.performer, ctx, personResolver, {
|
|
682
|
-
root: true
|
|
683
|
-
});
|
|
684
|
-
node.organizer = resolveRelation(node.organizer, ctx, organizationResolver, {
|
|
685
|
-
root: true
|
|
686
|
-
});
|
|
687
|
-
node.offers = resolveRelation(node.offers, ctx, offerResolver);
|
|
688
|
-
if (node.eventAttendanceMode)
|
|
689
|
-
node.eventAttendanceMode = withBase(node.eventAttendanceMode, "https://schema.org/");
|
|
690
|
-
if (node.eventStatus)
|
|
691
|
-
node.eventStatus = withBase(node.eventStatus, "https://schema.org/");
|
|
692
|
-
const isOnline = node.eventStatus === "https://schema.org/EventMovedOnline";
|
|
693
|
-
const dates = ["startDate", "previousStartDate", "endDate"];
|
|
694
|
-
dates.forEach((date) => {
|
|
695
|
-
if (!isOnline) {
|
|
696
|
-
if (node[date] instanceof Date && node[date].getHours() === 0 && node[date].getMinutes() === 0)
|
|
697
|
-
node[date] = resolvableDateToDate(node[date]);
|
|
698
|
-
} else {
|
|
699
|
-
node[date] = resolvableDateToIso(node[date]);
|
|
700
|
-
}
|
|
701
|
-
});
|
|
702
|
-
setIfEmpty(node, "endDate", node.startDate);
|
|
703
|
-
return node;
|
|
704
|
-
},
|
|
705
|
-
resolveRootNode(node, { find }) {
|
|
706
|
-
const identity = find(IdentityId);
|
|
707
|
-
if (identity)
|
|
708
|
-
setIfEmpty(node, "organizer", idReference(identity));
|
|
709
|
-
}
|
|
710
|
-
});
|
|
711
|
-
|
|
712
|
-
const howToStepDirectionResolver = defineSchemaOrgResolver({
|
|
713
|
-
cast(node) {
|
|
714
|
-
if (typeof node === "string") {
|
|
715
|
-
return {
|
|
716
|
-
text: node
|
|
717
|
-
};
|
|
718
|
-
}
|
|
719
|
-
return node;
|
|
720
|
-
},
|
|
721
|
-
defaults: {
|
|
722
|
-
"@type": "HowToDirection"
|
|
723
|
-
}
|
|
724
|
-
});
|
|
725
|
-
|
|
726
|
-
const howToStepResolver = defineSchemaOrgResolver({
|
|
727
|
-
cast(node) {
|
|
728
|
-
if (typeof node === "string") {
|
|
729
|
-
return {
|
|
730
|
-
text: node
|
|
731
|
-
};
|
|
732
|
-
}
|
|
733
|
-
return node;
|
|
734
|
-
},
|
|
735
|
-
defaults: {
|
|
736
|
-
"@type": "HowToStep"
|
|
737
|
-
},
|
|
738
|
-
resolve(step, ctx) {
|
|
739
|
-
if (step.url)
|
|
740
|
-
step.url = resolveWithBase(ctx.meta.url, step.url);
|
|
741
|
-
if (step.image) {
|
|
742
|
-
step.image = resolveRelation(step.image, ctx, imageResolver, {
|
|
743
|
-
root: true
|
|
744
|
-
});
|
|
745
|
-
}
|
|
746
|
-
if (step.itemListElement)
|
|
747
|
-
step.itemListElement = resolveRelation(step.itemListElement, ctx, howToStepDirectionResolver);
|
|
748
|
-
return step;
|
|
749
|
-
}
|
|
750
|
-
});
|
|
751
|
-
|
|
752
|
-
const HowToId = "#howto";
|
|
753
|
-
const howToResolver = defineSchemaOrgResolver({
|
|
754
|
-
defaults: {
|
|
755
|
-
"@type": "HowTo"
|
|
756
|
-
},
|
|
757
|
-
inheritMeta: [
|
|
758
|
-
"description",
|
|
759
|
-
"image",
|
|
760
|
-
"inLanguage",
|
|
761
|
-
{ meta: "title", key: "name" }
|
|
762
|
-
],
|
|
763
|
-
idPrefix: ["url", HowToId],
|
|
764
|
-
resolve(node, ctx) {
|
|
765
|
-
node.step = resolveRelation(node.step, ctx, howToStepResolver);
|
|
766
|
-
return node;
|
|
767
|
-
},
|
|
768
|
-
resolveRootNode(node, { find }) {
|
|
769
|
-
const webPage = find(PrimaryWebPageId);
|
|
770
|
-
if (webPage)
|
|
771
|
-
setIfEmpty(node, "mainEntityOfPage", idReference(webPage));
|
|
772
|
-
}
|
|
773
|
-
});
|
|
774
|
-
|
|
775
|
-
const itemListResolver = defineSchemaOrgResolver({
|
|
776
|
-
defaults: {
|
|
777
|
-
"@type": "ItemList"
|
|
778
|
-
},
|
|
779
|
-
resolve(node, ctx) {
|
|
780
|
-
if (node.itemListElement) {
|
|
781
|
-
let index = 1;
|
|
782
|
-
node.itemListElement = resolveRelation(node.itemListElement, ctx, listItemResolver, {
|
|
783
|
-
array: true,
|
|
784
|
-
afterResolve(node2) {
|
|
785
|
-
setIfEmpty(node2, "position", index++);
|
|
786
|
-
}
|
|
787
|
-
});
|
|
788
|
-
}
|
|
789
|
-
return node;
|
|
790
|
-
}
|
|
791
|
-
});
|
|
792
|
-
|
|
793
|
-
const quantitativeValueResolver = defineSchemaOrgResolver({
|
|
794
|
-
defaults: {
|
|
795
|
-
"@type": "QuantitativeValue"
|
|
796
|
-
}
|
|
797
|
-
});
|
|
798
|
-
const monetaryAmountResolver = defineSchemaOrgResolver({
|
|
799
|
-
defaults: {
|
|
800
|
-
"@type": "MonetaryAmount"
|
|
801
|
-
},
|
|
802
|
-
resolve(node, ctx) {
|
|
803
|
-
node.value = resolveRelation(node.value, ctx, quantitativeValueResolver);
|
|
804
|
-
return node;
|
|
805
|
-
}
|
|
806
|
-
});
|
|
807
|
-
|
|
808
|
-
const jobPostingResolver = defineSchemaOrgResolver({
|
|
809
|
-
defaults: {
|
|
810
|
-
"@type": "JobPosting"
|
|
811
|
-
},
|
|
812
|
-
resolve(node, ctx) {
|
|
813
|
-
node.datePosted = resolvableDateToIso(node.datePosted);
|
|
814
|
-
node.hiringOrganization = resolveRelation(node.hiringOrganization, ctx, organizationResolver);
|
|
815
|
-
node.jobLocation = resolveRelation(node.jobLocation, ctx, placeResolver);
|
|
816
|
-
node.baseSalary = resolveRelation(node.baseSalary, ctx, monetaryAmountResolver);
|
|
817
|
-
node.validThrough = resolvableDateToIso(node.validThrough);
|
|
818
|
-
return node;
|
|
819
|
-
}
|
|
820
|
-
});
|
|
821
|
-
|
|
822
|
-
const openingHoursResolver = defineSchemaOrgResolver({
|
|
823
|
-
defaults: {
|
|
824
|
-
"@type": "OpeningHoursSpecification",
|
|
825
|
-
"opens": "00:00",
|
|
826
|
-
"closes": "23:59"
|
|
827
|
-
}
|
|
828
|
-
});
|
|
829
|
-
|
|
830
|
-
const localBusinessResolver = defineSchemaOrgResolver({
|
|
831
|
-
defaults: {
|
|
832
|
-
"@type": ["Organization", "LocalBusiness"]
|
|
833
|
-
},
|
|
834
|
-
inheritMeta: [
|
|
835
|
-
{ key: "url", meta: "host" },
|
|
836
|
-
{ key: "currenciesAccepted", meta: "currency" }
|
|
837
|
-
],
|
|
838
|
-
idPrefix: ["host", IdentityId],
|
|
839
|
-
resolve(node, ctx) {
|
|
840
|
-
resolveDefaultType(node, ["Organization", "LocalBusiness"]);
|
|
841
|
-
node.address = resolveRelation(node.address, ctx, addressResolver);
|
|
842
|
-
node.openingHoursSpecification = resolveRelation(node.openingHoursSpecification, ctx, openingHoursResolver);
|
|
843
|
-
node.logo = resolveRelation(node.logo, ctx, imageResolver, {
|
|
844
|
-
afterResolve(logo) {
|
|
845
|
-
const hasLogo = !!ctx.find("#logo");
|
|
846
|
-
if (!hasLogo)
|
|
847
|
-
logo["@id"] = prefixId(ctx.meta.host, "#logo");
|
|
848
|
-
setIfEmpty(logo, "caption", node.name);
|
|
849
|
-
}
|
|
850
|
-
});
|
|
851
|
-
return node;
|
|
852
|
-
}
|
|
853
|
-
});
|
|
854
|
-
|
|
855
|
-
const ratingResolver = defineSchemaOrgResolver({
|
|
856
|
-
cast(node) {
|
|
857
|
-
if (node === "number") {
|
|
858
|
-
return {
|
|
859
|
-
ratingValue: node
|
|
860
|
-
};
|
|
861
|
-
}
|
|
862
|
-
return node;
|
|
863
|
-
},
|
|
864
|
-
defaults: {
|
|
865
|
-
"@type": "Rating",
|
|
866
|
-
"bestRating": 5,
|
|
867
|
-
"worstRating": 1
|
|
868
|
-
}
|
|
869
|
-
});
|
|
870
|
-
|
|
871
|
-
const reviewResolver = defineSchemaOrgResolver({
|
|
872
|
-
defaults: {
|
|
873
|
-
"@type": "Review"
|
|
874
|
-
},
|
|
875
|
-
inheritMeta: [
|
|
876
|
-
"inLanguage"
|
|
877
|
-
],
|
|
878
|
-
resolve(review, ctx) {
|
|
879
|
-
review.reviewRating = resolveRelation(review.reviewRating, ctx, ratingResolver);
|
|
880
|
-
review.author = resolveRelation(review.author, ctx, personResolver);
|
|
881
|
-
return review;
|
|
882
|
-
}
|
|
883
|
-
});
|
|
884
|
-
|
|
885
|
-
const videoResolver = defineSchemaOrgResolver({
|
|
886
|
-
cast(input) {
|
|
887
|
-
if (typeof input === "string") {
|
|
888
|
-
input = {
|
|
889
|
-
url: input
|
|
890
|
-
};
|
|
891
|
-
}
|
|
892
|
-
return input;
|
|
893
|
-
},
|
|
894
|
-
alias: "video",
|
|
895
|
-
defaults: {
|
|
896
|
-
"@type": "VideoObject"
|
|
897
|
-
},
|
|
898
|
-
inheritMeta: [
|
|
899
|
-
{ meta: "title", key: "name" },
|
|
900
|
-
"description",
|
|
901
|
-
"image",
|
|
902
|
-
"inLanguage",
|
|
903
|
-
{ meta: "datePublished", key: "uploadDate" }
|
|
904
|
-
],
|
|
905
|
-
idPrefix: "host",
|
|
906
|
-
resolve(video, ctx) {
|
|
907
|
-
if (video.uploadDate)
|
|
908
|
-
video.uploadDate = resolvableDateToIso(video.uploadDate);
|
|
909
|
-
video.url = resolveWithBase(ctx.meta.host, video.url);
|
|
910
|
-
if (video.caption && !video.description)
|
|
911
|
-
video.description = video.caption;
|
|
912
|
-
if (!video.description)
|
|
913
|
-
video.description = "No description";
|
|
914
|
-
if (video.thumbnailUrl)
|
|
915
|
-
video.thumbnailUrl = resolveRelation(video.thumbnailUrl, ctx, imageResolver);
|
|
916
|
-
return video;
|
|
917
|
-
},
|
|
918
|
-
resolveRootNode(video, { find }) {
|
|
919
|
-
if (video.image && !video.thumbnailUrl) {
|
|
920
|
-
const firstImage = asArray(video.image)[0];
|
|
921
|
-
setIfEmpty(video, "thumbnailUrl", find(firstImage["@id"])?.url);
|
|
922
|
-
}
|
|
923
|
-
}
|
|
924
|
-
});
|
|
925
|
-
|
|
926
|
-
const movieResolver = defineSchemaOrgResolver({
|
|
927
|
-
defaults: {
|
|
928
|
-
"@type": "Movie"
|
|
929
|
-
},
|
|
930
|
-
resolve(node, ctx) {
|
|
931
|
-
node.aggregateRating = resolveRelation(node.aggregateRating, ctx, aggregateRatingResolver);
|
|
932
|
-
node.review = resolveRelation(node.review, ctx, reviewResolver);
|
|
933
|
-
node.director = resolveRelation(node.director, ctx, personResolver);
|
|
934
|
-
node.actor = resolveRelation(node.actor, ctx, personResolver);
|
|
935
|
-
node.trailer = resolveRelation(node.trailer, ctx, videoResolver);
|
|
936
|
-
if (node.dateCreated)
|
|
937
|
-
node.dateCreated = resolvableDateToDate(node.dateCreated);
|
|
938
|
-
return node;
|
|
939
|
-
}
|
|
940
|
-
});
|
|
941
|
-
|
|
942
|
-
const defaults = {
|
|
943
|
-
ignoreUnknown: false,
|
|
944
|
-
respectType: false,
|
|
945
|
-
respectFunctionNames: false,
|
|
946
|
-
respectFunctionProperties: false,
|
|
947
|
-
unorderedObjects: true,
|
|
948
|
-
unorderedArrays: false,
|
|
949
|
-
unorderedSets: false
|
|
950
|
-
};
|
|
951
|
-
function objectHash(object, options = {}) {
|
|
952
|
-
options = { ...defaults, ...options };
|
|
953
|
-
const hasher = createHasher(options);
|
|
954
|
-
hasher.dispatch(object);
|
|
955
|
-
return hasher.toString();
|
|
45
|
+
function defineImage(input) {
|
|
46
|
+
return provideResolver(input, "image");
|
|
956
47
|
}
|
|
957
|
-
function
|
|
958
|
-
|
|
959
|
-
let context = [];
|
|
960
|
-
const write = (str) => {
|
|
961
|
-
buff.push(str);
|
|
962
|
-
};
|
|
963
|
-
return {
|
|
964
|
-
toString() {
|
|
965
|
-
return buff.join("");
|
|
966
|
-
},
|
|
967
|
-
getContext() {
|
|
968
|
-
return context;
|
|
969
|
-
},
|
|
970
|
-
dispatch(value) {
|
|
971
|
-
if (options.replacer) {
|
|
972
|
-
value = options.replacer(value);
|
|
973
|
-
}
|
|
974
|
-
const type = value === null ? "null" : typeof value;
|
|
975
|
-
return this["_" + type](value);
|
|
976
|
-
},
|
|
977
|
-
_object(object) {
|
|
978
|
-
const pattern = /\[object (.*)]/i;
|
|
979
|
-
const objString = Object.prototype.toString.call(object);
|
|
980
|
-
const _objType = pattern.exec(objString);
|
|
981
|
-
const objType = _objType ? _objType[1].toLowerCase() : "unknown:[" + objString.toLowerCase() + "]";
|
|
982
|
-
let objectNumber = null;
|
|
983
|
-
if ((objectNumber = context.indexOf(object)) >= 0) {
|
|
984
|
-
return this.dispatch("[CIRCULAR:" + objectNumber + "]");
|
|
985
|
-
} else {
|
|
986
|
-
context.push(object);
|
|
987
|
-
}
|
|
988
|
-
if (typeof Buffer !== "undefined" && Buffer.isBuffer && Buffer.isBuffer(object)) {
|
|
989
|
-
write("buffer:");
|
|
990
|
-
return write(object.toString("utf8"));
|
|
991
|
-
}
|
|
992
|
-
if (objType !== "object" && objType !== "function" && objType !== "asyncfunction") {
|
|
993
|
-
if (this["_" + objType]) {
|
|
994
|
-
this["_" + objType](object);
|
|
995
|
-
} else if (options.ignoreUnknown) {
|
|
996
|
-
return write("[" + objType + "]");
|
|
997
|
-
} else {
|
|
998
|
-
throw new Error('Unknown object type "' + objType + '"');
|
|
999
|
-
}
|
|
1000
|
-
} else {
|
|
1001
|
-
let keys = Object.keys(object);
|
|
1002
|
-
if (options.unorderedObjects) {
|
|
1003
|
-
keys = keys.sort();
|
|
1004
|
-
}
|
|
1005
|
-
if (options.respectType !== false && !isNativeFunction(object)) {
|
|
1006
|
-
keys.splice(0, 0, "prototype", "__proto__", "letructor");
|
|
1007
|
-
}
|
|
1008
|
-
if (options.excludeKeys) {
|
|
1009
|
-
keys = keys.filter(function(key) {
|
|
1010
|
-
return !options.excludeKeys(key);
|
|
1011
|
-
});
|
|
1012
|
-
}
|
|
1013
|
-
write("object:" + keys.length + ":");
|
|
1014
|
-
for (const key of keys) {
|
|
1015
|
-
this.dispatch(key);
|
|
1016
|
-
write(":");
|
|
1017
|
-
if (!options.excludeValues) {
|
|
1018
|
-
this.dispatch(object[key]);
|
|
1019
|
-
}
|
|
1020
|
-
write(",");
|
|
1021
|
-
}
|
|
1022
|
-
}
|
|
1023
|
-
},
|
|
1024
|
-
_array(arr, unordered) {
|
|
1025
|
-
unordered = typeof unordered !== "undefined" ? unordered : options.unorderedArrays !== false;
|
|
1026
|
-
write("array:" + arr.length + ":");
|
|
1027
|
-
if (!unordered || arr.length <= 1) {
|
|
1028
|
-
for (const entry of arr) {
|
|
1029
|
-
this.dispatch(entry);
|
|
1030
|
-
}
|
|
1031
|
-
return;
|
|
1032
|
-
}
|
|
1033
|
-
const contextAdditions = [];
|
|
1034
|
-
const entries = arr.map((entry) => {
|
|
1035
|
-
const hasher = createHasher(options);
|
|
1036
|
-
hasher.dispatch(entry);
|
|
1037
|
-
contextAdditions.push(hasher.getContext());
|
|
1038
|
-
return hasher.toString();
|
|
1039
|
-
});
|
|
1040
|
-
context = [...context, ...contextAdditions];
|
|
1041
|
-
entries.sort();
|
|
1042
|
-
return this._array(entries, false);
|
|
1043
|
-
},
|
|
1044
|
-
_date(date) {
|
|
1045
|
-
return write("date:" + date.toJSON());
|
|
1046
|
-
},
|
|
1047
|
-
_symbol(sym) {
|
|
1048
|
-
return write("symbol:" + sym.toString());
|
|
1049
|
-
},
|
|
1050
|
-
_error(err) {
|
|
1051
|
-
return write("error:" + err.toString());
|
|
1052
|
-
},
|
|
1053
|
-
_boolean(bool) {
|
|
1054
|
-
return write("bool:" + bool.toString());
|
|
1055
|
-
},
|
|
1056
|
-
_string(string) {
|
|
1057
|
-
write("string:" + string.length + ":");
|
|
1058
|
-
write(string.toString());
|
|
1059
|
-
},
|
|
1060
|
-
_function(fn) {
|
|
1061
|
-
write("fn:");
|
|
1062
|
-
if (isNativeFunction(fn)) {
|
|
1063
|
-
this.dispatch("[native]");
|
|
1064
|
-
} else {
|
|
1065
|
-
this.dispatch(fn.toString());
|
|
1066
|
-
}
|
|
1067
|
-
if (options.respectFunctionNames !== false) {
|
|
1068
|
-
this.dispatch("function-name:" + String(fn.name));
|
|
1069
|
-
}
|
|
1070
|
-
if (options.respectFunctionProperties) {
|
|
1071
|
-
this._object(fn);
|
|
1072
|
-
}
|
|
1073
|
-
},
|
|
1074
|
-
_number(number) {
|
|
1075
|
-
return write("number:" + number.toString());
|
|
1076
|
-
},
|
|
1077
|
-
_xml(xml) {
|
|
1078
|
-
return write("xml:" + xml.toString());
|
|
1079
|
-
},
|
|
1080
|
-
_null() {
|
|
1081
|
-
return write("Null");
|
|
1082
|
-
},
|
|
1083
|
-
_undefined() {
|
|
1084
|
-
return write("Undefined");
|
|
1085
|
-
},
|
|
1086
|
-
_regexp(regex) {
|
|
1087
|
-
return write("regex:" + regex.toString());
|
|
1088
|
-
},
|
|
1089
|
-
_uint8array(arr) {
|
|
1090
|
-
write("uint8array:");
|
|
1091
|
-
return this.dispatch(Array.prototype.slice.call(arr));
|
|
1092
|
-
},
|
|
1093
|
-
_uint8clampedarray(arr) {
|
|
1094
|
-
write("uint8clampedarray:");
|
|
1095
|
-
return this.dispatch(Array.prototype.slice.call(arr));
|
|
1096
|
-
},
|
|
1097
|
-
_int8array(arr) {
|
|
1098
|
-
write("int8array:");
|
|
1099
|
-
return this.dispatch(Array.prototype.slice.call(arr));
|
|
1100
|
-
},
|
|
1101
|
-
_uint16array(arr) {
|
|
1102
|
-
write("uint16array:");
|
|
1103
|
-
return this.dispatch(Array.prototype.slice.call(arr));
|
|
1104
|
-
},
|
|
1105
|
-
_int16array(arr) {
|
|
1106
|
-
write("int16array:");
|
|
1107
|
-
return this.dispatch(Array.prototype.slice.call(arr));
|
|
1108
|
-
},
|
|
1109
|
-
_uint32array(arr) {
|
|
1110
|
-
write("uint32array:");
|
|
1111
|
-
return this.dispatch(Array.prototype.slice.call(arr));
|
|
1112
|
-
},
|
|
1113
|
-
_int32array(arr) {
|
|
1114
|
-
write("int32array:");
|
|
1115
|
-
return this.dispatch(Array.prototype.slice.call(arr));
|
|
1116
|
-
},
|
|
1117
|
-
_float32array(arr) {
|
|
1118
|
-
write("float32array:");
|
|
1119
|
-
return this.dispatch(Array.prototype.slice.call(arr));
|
|
1120
|
-
},
|
|
1121
|
-
_float64array(arr) {
|
|
1122
|
-
write("float64array:");
|
|
1123
|
-
return this.dispatch(Array.prototype.slice.call(arr));
|
|
1124
|
-
},
|
|
1125
|
-
_arraybuffer(arr) {
|
|
1126
|
-
write("arraybuffer:");
|
|
1127
|
-
return this.dispatch(new Uint8Array(arr));
|
|
1128
|
-
},
|
|
1129
|
-
_url(url) {
|
|
1130
|
-
return write("url:" + url.toString());
|
|
1131
|
-
},
|
|
1132
|
-
_map(map) {
|
|
1133
|
-
write("map:");
|
|
1134
|
-
const arr = [...map];
|
|
1135
|
-
return this._array(arr, options.unorderedSets !== false);
|
|
1136
|
-
},
|
|
1137
|
-
_set(set) {
|
|
1138
|
-
write("set:");
|
|
1139
|
-
const arr = [...set];
|
|
1140
|
-
return this._array(arr, options.unorderedSets !== false);
|
|
1141
|
-
},
|
|
1142
|
-
_file(file) {
|
|
1143
|
-
write("file:");
|
|
1144
|
-
return this.dispatch([file.name, file.size, file.type, file.lastModfied]);
|
|
1145
|
-
},
|
|
1146
|
-
_blob() {
|
|
1147
|
-
if (options.ignoreUnknown) {
|
|
1148
|
-
return write("[blob]");
|
|
1149
|
-
}
|
|
1150
|
-
throw new Error('Hashing Blob objects is currently not supported\nUse "options.replacer" or "options.ignoreUnknown"\n');
|
|
1151
|
-
},
|
|
1152
|
-
_domwindow() {
|
|
1153
|
-
return write("domwindow");
|
|
1154
|
-
},
|
|
1155
|
-
_bigint(number) {
|
|
1156
|
-
return write("bigint:" + number.toString());
|
|
1157
|
-
},
|
|
1158
|
-
_process() {
|
|
1159
|
-
return write("process");
|
|
1160
|
-
},
|
|
1161
|
-
_timer() {
|
|
1162
|
-
return write("timer");
|
|
1163
|
-
},
|
|
1164
|
-
_pipe() {
|
|
1165
|
-
return write("pipe");
|
|
1166
|
-
},
|
|
1167
|
-
_tcp() {
|
|
1168
|
-
return write("tcp");
|
|
1169
|
-
},
|
|
1170
|
-
_udp() {
|
|
1171
|
-
return write("udp");
|
|
1172
|
-
},
|
|
1173
|
-
_tty() {
|
|
1174
|
-
return write("tty");
|
|
1175
|
-
},
|
|
1176
|
-
_statwatcher() {
|
|
1177
|
-
return write("statwatcher");
|
|
1178
|
-
},
|
|
1179
|
-
_securecontext() {
|
|
1180
|
-
return write("securecontext");
|
|
1181
|
-
},
|
|
1182
|
-
_connection() {
|
|
1183
|
-
return write("connection");
|
|
1184
|
-
},
|
|
1185
|
-
_zlib() {
|
|
1186
|
-
return write("zlib");
|
|
1187
|
-
},
|
|
1188
|
-
_context() {
|
|
1189
|
-
return write("context");
|
|
1190
|
-
},
|
|
1191
|
-
_nodescript() {
|
|
1192
|
-
return write("nodescript");
|
|
1193
|
-
},
|
|
1194
|
-
_httpparser() {
|
|
1195
|
-
return write("httpparser");
|
|
1196
|
-
},
|
|
1197
|
-
_dataview() {
|
|
1198
|
-
return write("dataview");
|
|
1199
|
-
},
|
|
1200
|
-
_signal() {
|
|
1201
|
-
return write("signal");
|
|
1202
|
-
},
|
|
1203
|
-
_fsevent() {
|
|
1204
|
-
return write("fsevent");
|
|
1205
|
-
},
|
|
1206
|
-
_tlswrap() {
|
|
1207
|
-
return write("tlswrap");
|
|
1208
|
-
}
|
|
1209
|
-
};
|
|
48
|
+
function defineJobPosting(input) {
|
|
49
|
+
return provideResolver(input, "jobPosting");
|
|
1210
50
|
}
|
|
1211
|
-
function
|
|
1212
|
-
|
|
1213
|
-
return false;
|
|
1214
|
-
}
|
|
1215
|
-
const exp = /^function\s+\w*\s*\(\s*\)\s*{\s+\[native code]\s+}$/i;
|
|
1216
|
-
return exp.exec(Function.prototype.toString.call(f)) != null;
|
|
51
|
+
function defineLocalBusiness(input) {
|
|
52
|
+
return provideResolver(input, "localBusiness");
|
|
1217
53
|
}
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
constructor(words, sigBytes) {
|
|
1221
|
-
words = this.words = words || [];
|
|
1222
|
-
this.sigBytes = sigBytes !== void 0 ? sigBytes : words.length * 4;
|
|
1223
|
-
}
|
|
1224
|
-
toString(encoder) {
|
|
1225
|
-
return (encoder || Hex).stringify(this);
|
|
1226
|
-
}
|
|
1227
|
-
concat(wordArray) {
|
|
1228
|
-
this.clamp();
|
|
1229
|
-
if (this.sigBytes % 4) {
|
|
1230
|
-
for (let i = 0; i < wordArray.sigBytes; i++) {
|
|
1231
|
-
const thatByte = wordArray.words[i >>> 2] >>> 24 - i % 4 * 8 & 255;
|
|
1232
|
-
this.words[this.sigBytes + i >>> 2] |= thatByte << 24 - (this.sigBytes + i) % 4 * 8;
|
|
1233
|
-
}
|
|
1234
|
-
} else {
|
|
1235
|
-
for (let j = 0; j < wordArray.sigBytes; j += 4) {
|
|
1236
|
-
this.words[this.sigBytes + j >>> 2] = wordArray.words[j >>> 2];
|
|
1237
|
-
}
|
|
1238
|
-
}
|
|
1239
|
-
this.sigBytes += wordArray.sigBytes;
|
|
1240
|
-
return this;
|
|
1241
|
-
}
|
|
1242
|
-
clamp() {
|
|
1243
|
-
this.words[this.sigBytes >>> 2] &= 4294967295 << 32 - this.sigBytes % 4 * 8;
|
|
1244
|
-
this.words.length = Math.ceil(this.sigBytes / 4);
|
|
1245
|
-
}
|
|
1246
|
-
clone() {
|
|
1247
|
-
return new WordArray([...this.words]);
|
|
1248
|
-
}
|
|
54
|
+
function defineOffer(input) {
|
|
55
|
+
return provideResolver(input, "offer");
|
|
1249
56
|
}
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
const hexChars = [];
|
|
1253
|
-
for (let i = 0; i < wordArray.sigBytes; i++) {
|
|
1254
|
-
const bite = wordArray.words[i >>> 2] >>> 24 - i % 4 * 8 & 255;
|
|
1255
|
-
hexChars.push(
|
|
1256
|
-
(bite >>> 4).toString(16),
|
|
1257
|
-
(bite & 15).toString(16)
|
|
1258
|
-
);
|
|
1259
|
-
}
|
|
1260
|
-
return hexChars.join("");
|
|
1261
|
-
}
|
|
1262
|
-
};
|
|
1263
|
-
const Base64 = {
|
|
1264
|
-
stringify(wordArray) {
|
|
1265
|
-
const keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
1266
|
-
const base64Chars = [];
|
|
1267
|
-
for (let i = 0; i < wordArray.sigBytes; i += 3) {
|
|
1268
|
-
const byte1 = wordArray.words[i >>> 2] >>> 24 - i % 4 * 8 & 255;
|
|
1269
|
-
const byte2 = wordArray.words[i + 1 >>> 2] >>> 24 - (i + 1) % 4 * 8 & 255;
|
|
1270
|
-
const byte3 = wordArray.words[i + 2 >>> 2] >>> 24 - (i + 2) % 4 * 8 & 255;
|
|
1271
|
-
const triplet = byte1 << 16 | byte2 << 8 | byte3;
|
|
1272
|
-
for (let j = 0; j < 4 && i * 8 + j * 6 < wordArray.sigBytes * 8; j++) {
|
|
1273
|
-
base64Chars.push(keyStr.charAt(triplet >>> 6 * (3 - j) & 63));
|
|
1274
|
-
}
|
|
1275
|
-
}
|
|
1276
|
-
return base64Chars.join("");
|
|
1277
|
-
}
|
|
1278
|
-
};
|
|
1279
|
-
const Latin1 = {
|
|
1280
|
-
parse(latin1Str) {
|
|
1281
|
-
const latin1StrLength = latin1Str.length;
|
|
1282
|
-
const words = [];
|
|
1283
|
-
for (let i = 0; i < latin1StrLength; i++) {
|
|
1284
|
-
words[i >>> 2] |= (latin1Str.charCodeAt(i) & 255) << 24 - i % 4 * 8;
|
|
1285
|
-
}
|
|
1286
|
-
return new WordArray(words, latin1StrLength);
|
|
1287
|
-
}
|
|
1288
|
-
};
|
|
1289
|
-
const Utf8 = {
|
|
1290
|
-
parse(utf8Str) {
|
|
1291
|
-
return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
|
|
1292
|
-
}
|
|
1293
|
-
};
|
|
1294
|
-
class BufferedBlockAlgorithm {
|
|
1295
|
-
constructor() {
|
|
1296
|
-
this._minBufferSize = 0;
|
|
1297
|
-
this.blockSize = 512 / 32;
|
|
1298
|
-
this.reset();
|
|
1299
|
-
}
|
|
1300
|
-
reset() {
|
|
1301
|
-
this._data = new WordArray();
|
|
1302
|
-
this._nDataBytes = 0;
|
|
1303
|
-
}
|
|
1304
|
-
_append(data) {
|
|
1305
|
-
if (typeof data === "string") {
|
|
1306
|
-
data = Utf8.parse(data);
|
|
1307
|
-
}
|
|
1308
|
-
this._data.concat(data);
|
|
1309
|
-
this._nDataBytes += data.sigBytes;
|
|
1310
|
-
}
|
|
1311
|
-
_doProcessBlock(_dataWords, _offset) {
|
|
1312
|
-
}
|
|
1313
|
-
_process(doFlush) {
|
|
1314
|
-
let processedWords;
|
|
1315
|
-
let nBlocksReady = this._data.sigBytes / (this.blockSize * 4);
|
|
1316
|
-
if (doFlush) {
|
|
1317
|
-
nBlocksReady = Math.ceil(nBlocksReady);
|
|
1318
|
-
} else {
|
|
1319
|
-
nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);
|
|
1320
|
-
}
|
|
1321
|
-
const nWordsReady = nBlocksReady * this.blockSize;
|
|
1322
|
-
const nBytesReady = Math.min(nWordsReady * 4, this._data.sigBytes);
|
|
1323
|
-
if (nWordsReady) {
|
|
1324
|
-
for (let offset = 0; offset < nWordsReady; offset += this.blockSize) {
|
|
1325
|
-
this._doProcessBlock(this._data.words, offset);
|
|
1326
|
-
}
|
|
1327
|
-
processedWords = this._data.words.splice(0, nWordsReady);
|
|
1328
|
-
this._data.sigBytes -= nBytesReady;
|
|
1329
|
-
}
|
|
1330
|
-
return new WordArray(processedWords, nBytesReady);
|
|
1331
|
-
}
|
|
57
|
+
function defineOpeningHours(input) {
|
|
58
|
+
return provideResolver(input, "openingHours");
|
|
1332
59
|
}
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
this._append(messageUpdate);
|
|
1336
|
-
this._process();
|
|
1337
|
-
return this;
|
|
1338
|
-
}
|
|
1339
|
-
finalize(messageUpdate) {
|
|
1340
|
-
if (messageUpdate) {
|
|
1341
|
-
this._append(messageUpdate);
|
|
1342
|
-
}
|
|
1343
|
-
}
|
|
60
|
+
function defineOrganization(input) {
|
|
61
|
+
return provideResolver(input, "organization");
|
|
1344
62
|
}
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
const K = [1116352408, 1899447441, -1245643825, -373957723, 961987163, 1508970993, -1841331548, -1424204075, -670586216, 310598401, 607225278, 1426881987, 1925078388, -2132889090, -1680079193, -1046744716, -459576895, -272742522, 264347078, 604807628, 770255983, 1249150122, 1555081692, 1996064986, -1740746414, -1473132947, -1341970488, -1084653625, -958395405, -710438585, 113926993, 338241895, 666307205, 773529912, 1294757372, 1396182291, 1695183700, 1986661051, -2117940946, -1838011259, -1564481375, -1474664885, -1035236496, -949202525, -778901479, -694614492, -200395387, 275423344, 430227734, 506948616, 659060556, 883997877, 958139571, 1322822218, 1537002063, 1747873779, 1955562222, 2024104815, -2067236844, -1933114872, -1866530822, -1538233109, -1090935817, -965641998];
|
|
1348
|
-
const W = [];
|
|
1349
|
-
class SHA256 extends Hasher {
|
|
1350
|
-
constructor() {
|
|
1351
|
-
super();
|
|
1352
|
-
this.reset();
|
|
1353
|
-
}
|
|
1354
|
-
reset() {
|
|
1355
|
-
super.reset();
|
|
1356
|
-
this._hash = new WordArray([...H]);
|
|
1357
|
-
}
|
|
1358
|
-
_doProcessBlock(M, offset) {
|
|
1359
|
-
const H2 = this._hash.words;
|
|
1360
|
-
let a = H2[0];
|
|
1361
|
-
let b = H2[1];
|
|
1362
|
-
let c = H2[2];
|
|
1363
|
-
let d = H2[3];
|
|
1364
|
-
let e = H2[4];
|
|
1365
|
-
let f = H2[5];
|
|
1366
|
-
let g = H2[6];
|
|
1367
|
-
let h = H2[7];
|
|
1368
|
-
for (let i = 0; i < 64; i++) {
|
|
1369
|
-
if (i < 16) {
|
|
1370
|
-
W[i] = M[offset + i] | 0;
|
|
1371
|
-
} else {
|
|
1372
|
-
const gamma0x = W[i - 15];
|
|
1373
|
-
const gamma0 = (gamma0x << 25 | gamma0x >>> 7) ^ (gamma0x << 14 | gamma0x >>> 18) ^ gamma0x >>> 3;
|
|
1374
|
-
const gamma1x = W[i - 2];
|
|
1375
|
-
const gamma1 = (gamma1x << 15 | gamma1x >>> 17) ^ (gamma1x << 13 | gamma1x >>> 19) ^ gamma1x >>> 10;
|
|
1376
|
-
W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16];
|
|
1377
|
-
}
|
|
1378
|
-
const ch = e & f ^ ~e & g;
|
|
1379
|
-
const maj = a & b ^ a & c ^ b & c;
|
|
1380
|
-
const sigma0 = (a << 30 | a >>> 2) ^ (a << 19 | a >>> 13) ^ (a << 10 | a >>> 22);
|
|
1381
|
-
const sigma1 = (e << 26 | e >>> 6) ^ (e << 21 | e >>> 11) ^ (e << 7 | e >>> 25);
|
|
1382
|
-
const t1 = h + sigma1 + ch + K[i] + W[i];
|
|
1383
|
-
const t2 = sigma0 + maj;
|
|
1384
|
-
h = g;
|
|
1385
|
-
g = f;
|
|
1386
|
-
f = e;
|
|
1387
|
-
e = d + t1 | 0;
|
|
1388
|
-
d = c;
|
|
1389
|
-
c = b;
|
|
1390
|
-
b = a;
|
|
1391
|
-
a = t1 + t2 | 0;
|
|
1392
|
-
}
|
|
1393
|
-
H2[0] = H2[0] + a | 0;
|
|
1394
|
-
H2[1] = H2[1] + b | 0;
|
|
1395
|
-
H2[2] = H2[2] + c | 0;
|
|
1396
|
-
H2[3] = H2[3] + d | 0;
|
|
1397
|
-
H2[4] = H2[4] + e | 0;
|
|
1398
|
-
H2[5] = H2[5] + f | 0;
|
|
1399
|
-
H2[6] = H2[6] + g | 0;
|
|
1400
|
-
H2[7] = H2[7] + h | 0;
|
|
1401
|
-
}
|
|
1402
|
-
finalize(messageUpdate) {
|
|
1403
|
-
super.finalize(messageUpdate);
|
|
1404
|
-
const nBitsTotal = this._nDataBytes * 8;
|
|
1405
|
-
const nBitsLeft = this._data.sigBytes * 8;
|
|
1406
|
-
this._data.words[nBitsLeft >>> 5] |= 128 << 24 - nBitsLeft % 32;
|
|
1407
|
-
this._data.words[(nBitsLeft + 64 >>> 9 << 4) + 14] = Math.floor(nBitsTotal / 4294967296);
|
|
1408
|
-
this._data.words[(nBitsLeft + 64 >>> 9 << 4) + 15] = nBitsTotal;
|
|
1409
|
-
this._data.sigBytes = this._data.words.length * 4;
|
|
1410
|
-
this._process();
|
|
1411
|
-
return this._hash;
|
|
1412
|
-
}
|
|
63
|
+
function definePerson(input) {
|
|
64
|
+
return provideResolver(input, "person");
|
|
1413
65
|
}
|
|
1414
|
-
function
|
|
1415
|
-
return
|
|
66
|
+
function defineProduct(input) {
|
|
67
|
+
return provideResolver(input, "product");
|
|
1416
68
|
}
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
const hashed = typeof object === "string" ? object : objectHash(object, options);
|
|
1420
|
-
return sha256base64(hashed).slice(0, 10);
|
|
69
|
+
function defineQuestion(input) {
|
|
70
|
+
return provideResolver(input, "question");
|
|
1421
71
|
}
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
const productResolver = defineSchemaOrgResolver({
|
|
1425
|
-
defaults: {
|
|
1426
|
-
"@type": "Product"
|
|
1427
|
-
},
|
|
1428
|
-
inheritMeta: [
|
|
1429
|
-
"description",
|
|
1430
|
-
"image",
|
|
1431
|
-
{ meta: "title", key: "name" }
|
|
1432
|
-
],
|
|
1433
|
-
idPrefix: ["url", ProductId],
|
|
1434
|
-
resolve(node, ctx) {
|
|
1435
|
-
setIfEmpty(node, "sku", hash(node.name));
|
|
1436
|
-
node.aggregateOffer = resolveRelation(node.aggregateOffer, ctx, aggregateOfferResolver);
|
|
1437
|
-
node.aggregateRating = resolveRelation(node.aggregateRating, ctx, aggregateRatingResolver);
|
|
1438
|
-
node.offers = resolveRelation(node.offers, ctx, offerResolver);
|
|
1439
|
-
node.review = resolveRelation(node.review, ctx, reviewResolver);
|
|
1440
|
-
return node;
|
|
1441
|
-
},
|
|
1442
|
-
resolveRootNode(product, { find }) {
|
|
1443
|
-
const webPage = find(PrimaryWebPageId);
|
|
1444
|
-
const identity = find(IdentityId);
|
|
1445
|
-
if (identity)
|
|
1446
|
-
setIfEmpty(product, "brand", idReference(identity));
|
|
1447
|
-
if (webPage)
|
|
1448
|
-
setIfEmpty(product, "mainEntityOfPage", idReference(webPage));
|
|
1449
|
-
return product;
|
|
1450
|
-
}
|
|
1451
|
-
});
|
|
1452
|
-
|
|
1453
|
-
const answerResolver = defineSchemaOrgResolver({
|
|
1454
|
-
cast(node) {
|
|
1455
|
-
if (typeof node === "string") {
|
|
1456
|
-
return {
|
|
1457
|
-
text: node
|
|
1458
|
-
};
|
|
1459
|
-
}
|
|
1460
|
-
return node;
|
|
1461
|
-
},
|
|
1462
|
-
defaults: {
|
|
1463
|
-
"@type": "Answer"
|
|
1464
|
-
}
|
|
1465
|
-
});
|
|
1466
|
-
|
|
1467
|
-
const questionResolver = defineSchemaOrgResolver({
|
|
1468
|
-
defaults: {
|
|
1469
|
-
"@type": "Question"
|
|
1470
|
-
},
|
|
1471
|
-
inheritMeta: [
|
|
1472
|
-
"inLanguage"
|
|
1473
|
-
],
|
|
1474
|
-
idPrefix: "url",
|
|
1475
|
-
resolve(question, ctx) {
|
|
1476
|
-
if (question.question)
|
|
1477
|
-
question.name = question.question;
|
|
1478
|
-
if (question.answer)
|
|
1479
|
-
question.acceptedAnswer = question.answer;
|
|
1480
|
-
question.acceptedAnswer = resolveRelation(question.acceptedAnswer, ctx, answerResolver);
|
|
1481
|
-
return question;
|
|
1482
|
-
},
|
|
1483
|
-
resolveRootNode(question, { find }) {
|
|
1484
|
-
const webPage = find(PrimaryWebPageId);
|
|
1485
|
-
if (webPage && asArray(webPage["@type"]).includes("FAQPage"))
|
|
1486
|
-
dedupeMerge(webPage, "mainEntity", idReference(question));
|
|
1487
|
-
}
|
|
1488
|
-
});
|
|
1489
|
-
|
|
1490
|
-
const RecipeId = "#recipe";
|
|
1491
|
-
const recipeResolver = defineSchemaOrgResolver({
|
|
1492
|
-
defaults: {
|
|
1493
|
-
"@type": "Recipe"
|
|
1494
|
-
},
|
|
1495
|
-
inheritMeta: [
|
|
1496
|
-
{ meta: "title", key: "name" },
|
|
1497
|
-
"description",
|
|
1498
|
-
"image",
|
|
1499
|
-
"datePublished"
|
|
1500
|
-
],
|
|
1501
|
-
idPrefix: ["url", RecipeId],
|
|
1502
|
-
resolve(node, ctx) {
|
|
1503
|
-
node.recipeInstructions = resolveRelation(node.recipeInstructions, ctx, howToStepResolver);
|
|
1504
|
-
return node;
|
|
1505
|
-
},
|
|
1506
|
-
resolveRootNode(node, { find }) {
|
|
1507
|
-
const article = find(PrimaryArticleId);
|
|
1508
|
-
const webPage = find(PrimaryWebPageId);
|
|
1509
|
-
if (article)
|
|
1510
|
-
setIfEmpty(node, "mainEntityOfPage", idReference(article));
|
|
1511
|
-
else if (webPage)
|
|
1512
|
-
setIfEmpty(node, "mainEntityOfPage", idReference(webPage));
|
|
1513
|
-
if (article?.author)
|
|
1514
|
-
setIfEmpty(node, "author", article.author);
|
|
1515
|
-
return node;
|
|
1516
|
-
}
|
|
1517
|
-
});
|
|
1518
|
-
|
|
1519
|
-
const softwareAppResolver = defineSchemaOrgResolver({
|
|
1520
|
-
defaults: {
|
|
1521
|
-
"@type": "SoftwareApplication"
|
|
1522
|
-
},
|
|
1523
|
-
resolve(node, ctx) {
|
|
1524
|
-
resolveDefaultType(node, "SoftwareApplication");
|
|
1525
|
-
node.offers = resolveRelation(node.offers, ctx, offerResolver);
|
|
1526
|
-
node.aggregateRating = resolveRelation(node.aggregateRating, ctx, aggregateRatingResolver);
|
|
1527
|
-
node.review = resolveRelation(node.review, ctx, reviewResolver);
|
|
1528
|
-
return node;
|
|
1529
|
-
}
|
|
1530
|
-
});
|
|
1531
|
-
|
|
1532
|
-
function loadResolver(resolver) {
|
|
1533
|
-
switch (resolver) {
|
|
1534
|
-
case "address":
|
|
1535
|
-
return addressResolver;
|
|
1536
|
-
case "aggregateOffer":
|
|
1537
|
-
return aggregateOfferResolver;
|
|
1538
|
-
case "aggregateRating":
|
|
1539
|
-
return aggregateRatingResolver;
|
|
1540
|
-
case "article":
|
|
1541
|
-
return articleResolver;
|
|
1542
|
-
case "breadcrumb":
|
|
1543
|
-
return breadcrumbResolver;
|
|
1544
|
-
case "comment":
|
|
1545
|
-
return commentResolver;
|
|
1546
|
-
case "event":
|
|
1547
|
-
return eventResolver;
|
|
1548
|
-
case "virtualLocation":
|
|
1549
|
-
return virtualLocationResolver;
|
|
1550
|
-
case "place":
|
|
1551
|
-
return placeResolver;
|
|
1552
|
-
case "howTo":
|
|
1553
|
-
return howToResolver;
|
|
1554
|
-
case "howToStep":
|
|
1555
|
-
return howToStepResolver;
|
|
1556
|
-
case "image":
|
|
1557
|
-
return imageResolver;
|
|
1558
|
-
case "localBusiness":
|
|
1559
|
-
return localBusinessResolver;
|
|
1560
|
-
case "offer":
|
|
1561
|
-
return offerResolver;
|
|
1562
|
-
case "openingHours":
|
|
1563
|
-
return openingHoursResolver;
|
|
1564
|
-
case "organization":
|
|
1565
|
-
return organizationResolver;
|
|
1566
|
-
case "person":
|
|
1567
|
-
return personResolver;
|
|
1568
|
-
case "product":
|
|
1569
|
-
return productResolver;
|
|
1570
|
-
case "question":
|
|
1571
|
-
return questionResolver;
|
|
1572
|
-
case "recipe":
|
|
1573
|
-
return recipeResolver;
|
|
1574
|
-
case "review":
|
|
1575
|
-
return reviewResolver;
|
|
1576
|
-
case "video":
|
|
1577
|
-
return videoResolver;
|
|
1578
|
-
case "webPage":
|
|
1579
|
-
return webPageResolver;
|
|
1580
|
-
case "webSite":
|
|
1581
|
-
return webSiteResolver;
|
|
1582
|
-
case "book":
|
|
1583
|
-
return bookResolver;
|
|
1584
|
-
case "course":
|
|
1585
|
-
return courseResolver;
|
|
1586
|
-
case "itemList":
|
|
1587
|
-
return itemListResolver;
|
|
1588
|
-
case "jobPosting":
|
|
1589
|
-
return jobPostingResolver;
|
|
1590
|
-
case "listItem":
|
|
1591
|
-
return listItemResolver;
|
|
1592
|
-
case "movie":
|
|
1593
|
-
return movieResolver;
|
|
1594
|
-
case "searchAction":
|
|
1595
|
-
return searchActionResolver;
|
|
1596
|
-
case "readAction":
|
|
1597
|
-
return readActionResolver;
|
|
1598
|
-
case "softwareApp":
|
|
1599
|
-
return softwareAppResolver;
|
|
1600
|
-
case "bookEdition":
|
|
1601
|
-
return bookEditionResolver;
|
|
1602
|
-
}
|
|
1603
|
-
return null;
|
|
72
|
+
function defineRecipe(input) {
|
|
73
|
+
return provideResolver(input, "recipe");
|
|
1604
74
|
}
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
__proto__: null,
|
|
1608
|
-
loadResolver: loadResolver
|
|
1609
|
-
};
|
|
1610
|
-
|
|
1611
|
-
const resolveMeta = (meta) => {
|
|
1612
|
-
if (!meta.host && meta.canonicalHost)
|
|
1613
|
-
meta.host = meta.canonicalHost;
|
|
1614
|
-
if (!meta.tagPosition && meta.position)
|
|
1615
|
-
meta.tagPosition = meta.position;
|
|
1616
|
-
if (!meta.currency && meta.defaultCurrency)
|
|
1617
|
-
meta.currency = meta.defaultCurrency;
|
|
1618
|
-
if (!meta.inLanguage && meta.defaultLanguage)
|
|
1619
|
-
meta.inLanguage = meta.defaultLanguage;
|
|
1620
|
-
if (!meta.path)
|
|
1621
|
-
meta.path = "/";
|
|
1622
|
-
if (!meta.host && typeof document !== "undefined")
|
|
1623
|
-
meta.host = document.location.host;
|
|
1624
|
-
if (!meta.url && meta.canonicalUrl)
|
|
1625
|
-
meta.url = meta.canonicalUrl;
|
|
1626
|
-
if (meta.path !== "/") {
|
|
1627
|
-
if (meta.trailingSlash && !hasTrailingSlash(meta.path))
|
|
1628
|
-
meta.path = withTrailingSlash(meta.path);
|
|
1629
|
-
else if (!meta.trailingSlash && hasTrailingSlash(meta.path))
|
|
1630
|
-
meta.path = withoutTrailingSlash(meta.path);
|
|
1631
|
-
}
|
|
1632
|
-
meta.url = joinURL(meta.host, meta.path);
|
|
1633
|
-
return {
|
|
1634
|
-
...meta,
|
|
1635
|
-
host: meta.host,
|
|
1636
|
-
url: meta.url,
|
|
1637
|
-
currency: meta.currency,
|
|
1638
|
-
image: meta.image,
|
|
1639
|
-
inLanguage: meta.inLanguage,
|
|
1640
|
-
title: meta.title,
|
|
1641
|
-
description: meta.description,
|
|
1642
|
-
datePublished: meta.datePublished,
|
|
1643
|
-
dateModified: meta.dateModified
|
|
1644
|
-
};
|
|
1645
|
-
};
|
|
1646
|
-
const resolveNode = (node, ctx, resolver) => {
|
|
1647
|
-
if (resolver?.cast)
|
|
1648
|
-
node = resolver.cast(node, ctx);
|
|
1649
|
-
if (resolver?.defaults) {
|
|
1650
|
-
let defaults = resolver.defaults || {};
|
|
1651
|
-
if (typeof defaults === "function")
|
|
1652
|
-
defaults = defaults(ctx);
|
|
1653
|
-
node = {
|
|
1654
|
-
...defaults,
|
|
1655
|
-
...node
|
|
1656
|
-
};
|
|
1657
|
-
}
|
|
1658
|
-
resolver.inheritMeta?.forEach((entry) => {
|
|
1659
|
-
if (typeof entry === "string")
|
|
1660
|
-
setIfEmpty(node, entry, ctx.meta[entry]);
|
|
1661
|
-
else
|
|
1662
|
-
setIfEmpty(node, entry.key, ctx.meta[entry.meta]);
|
|
1663
|
-
});
|
|
1664
|
-
if (resolver?.resolve)
|
|
1665
|
-
node = resolver.resolve(node, ctx);
|
|
1666
|
-
for (const k in node) {
|
|
1667
|
-
const v = node[k];
|
|
1668
|
-
if (typeof v === "object" && v?._resolver)
|
|
1669
|
-
node[k] = resolveRelation(v, ctx, v._resolver);
|
|
1670
|
-
}
|
|
1671
|
-
stripEmptyProperties(node);
|
|
1672
|
-
return node;
|
|
1673
|
-
};
|
|
1674
|
-
const resolveNodeId = (node, ctx, resolver, resolveAsRoot = false) => {
|
|
1675
|
-
const prefix = Array.isArray(resolver.idPrefix) ? resolver.idPrefix[0] : resolver.idPrefix;
|
|
1676
|
-
if (!prefix)
|
|
1677
|
-
return node;
|
|
1678
|
-
if (node["@id"] && !node["@id"].startsWith(ctx.meta.host)) {
|
|
1679
|
-
node["@id"] = prefixId(ctx.meta[prefix], node["@id"]);
|
|
1680
|
-
return node;
|
|
1681
|
-
}
|
|
1682
|
-
const rootId = Array.isArray(resolver.idPrefix) ? resolver.idPrefix?.[1] : void 0;
|
|
1683
|
-
if (resolveAsRoot && rootId) {
|
|
1684
|
-
node["@id"] = prefixId(ctx.meta[prefix], rootId);
|
|
1685
|
-
}
|
|
1686
|
-
if (!node["@id"]) {
|
|
1687
|
-
let alias = resolver?.alias;
|
|
1688
|
-
if (!alias) {
|
|
1689
|
-
const type = asArray(node["@type"])?.[0] || "";
|
|
1690
|
-
alias = type.toLowerCase();
|
|
1691
|
-
}
|
|
1692
|
-
const hashNodeData = {};
|
|
1693
|
-
Object.entries(node).forEach(([key, val]) => {
|
|
1694
|
-
if (!key.startsWith("_"))
|
|
1695
|
-
hashNodeData[key] = val;
|
|
1696
|
-
});
|
|
1697
|
-
node["@id"] = prefixId(ctx.meta[prefix], `#/schema/${alias}/${hashCode(JSON.stringify(hashNodeData))}`);
|
|
1698
|
-
}
|
|
1699
|
-
return node;
|
|
1700
|
-
};
|
|
1701
|
-
function resolveRelation(input, ctx, fallbackResolver, options = {}) {
|
|
1702
|
-
if (!input)
|
|
1703
|
-
return input;
|
|
1704
|
-
const ids = asArray(input).map((a) => {
|
|
1705
|
-
if (Object.keys(a).length === 1 && a["@id"])
|
|
1706
|
-
return a;
|
|
1707
|
-
let resolver = fallbackResolver;
|
|
1708
|
-
if (a._resolver) {
|
|
1709
|
-
resolver = a._resolver;
|
|
1710
|
-
if (typeof resolver === "string")
|
|
1711
|
-
resolver = loadResolver(resolver);
|
|
1712
|
-
delete a._resolver;
|
|
1713
|
-
}
|
|
1714
|
-
if (!resolver)
|
|
1715
|
-
return a;
|
|
1716
|
-
let node = resolveNode(a, ctx, resolver);
|
|
1717
|
-
if (options.afterResolve)
|
|
1718
|
-
options.afterResolve(node);
|
|
1719
|
-
if (options.generateId || options.root)
|
|
1720
|
-
node = resolveNodeId(node, ctx, resolver, false);
|
|
1721
|
-
if (options.root) {
|
|
1722
|
-
if (resolver.resolveRootNode)
|
|
1723
|
-
resolver.resolveRootNode(node, ctx);
|
|
1724
|
-
ctx.push(node);
|
|
1725
|
-
return idReference(node["@id"]);
|
|
1726
|
-
}
|
|
1727
|
-
return node;
|
|
1728
|
-
});
|
|
1729
|
-
if (!options.array && ids.length === 1)
|
|
1730
|
-
return ids[0];
|
|
1731
|
-
return ids;
|
|
75
|
+
function defineReview(input) {
|
|
76
|
+
return provideResolver(input, "review");
|
|
1732
77
|
}
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
return
|
|
1765
|
-
}
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
const ctx = {
|
|
1769
|
-
find(id) {
|
|
1770
|
-
const key = resolveAsGraphKey(id);
|
|
1771
|
-
return ctx.nodes.filter((n) => !!n["@id"]).find((n) => resolveAsGraphKey(n["@id"]) === key);
|
|
1772
|
-
},
|
|
1773
|
-
push(input) {
|
|
1774
|
-
asArray(input).forEach((node) => {
|
|
1775
|
-
const registeredNode = node;
|
|
1776
|
-
ctx.nodes.push(registeredNode);
|
|
1777
|
-
});
|
|
1778
|
-
},
|
|
1779
|
-
resolveGraph(meta) {
|
|
1780
|
-
ctx.meta = resolveMeta({ ...meta });
|
|
1781
|
-
ctx.nodes.forEach((node, key) => {
|
|
1782
|
-
const resolver = node._resolver;
|
|
1783
|
-
if (resolver) {
|
|
1784
|
-
node = resolveNode(node, ctx, resolver);
|
|
1785
|
-
node = resolveNodeId(node, ctx, resolver, true);
|
|
1786
|
-
}
|
|
1787
|
-
ctx.nodes[key] = node;
|
|
1788
|
-
});
|
|
1789
|
-
ctx.nodes.forEach((node) => {
|
|
1790
|
-
if (node.image && typeof node.image === "string") {
|
|
1791
|
-
node.image = resolveRelation(node.image, ctx, imageResolver, {
|
|
1792
|
-
root: true
|
|
1793
|
-
});
|
|
1794
|
-
}
|
|
1795
|
-
if (node._resolver?.resolveRootNode)
|
|
1796
|
-
node._resolver.resolveRootNode(node, ctx);
|
|
1797
|
-
delete node._resolver;
|
|
1798
|
-
});
|
|
1799
|
-
return dedupeNodes(ctx.nodes);
|
|
1800
|
-
},
|
|
1801
|
-
nodes: [],
|
|
1802
|
-
meta: {}
|
|
1803
|
-
};
|
|
1804
|
-
return ctx;
|
|
1805
|
-
};
|
|
1806
|
-
|
|
1807
|
-
function SchemaOrgUnheadPlugin(config, meta) {
|
|
1808
|
-
config = resolveMeta({ ...config });
|
|
1809
|
-
let graph;
|
|
1810
|
-
const resolvedMeta = {};
|
|
1811
|
-
return {
|
|
1812
|
-
hooks: {
|
|
1813
|
-
"entries:resolve": function() {
|
|
1814
|
-
graph = createSchemaOrgGraph();
|
|
1815
|
-
},
|
|
1816
|
-
"tag:normalise": async function({ tag }) {
|
|
1817
|
-
if (tag.key === "schema-org-graph") {
|
|
1818
|
-
const { loadResolver } = await Promise.resolve().then(function () { return resolver; });
|
|
1819
|
-
const nodes = await tag.props.nodes;
|
|
1820
|
-
for (const node of Array.isArray(nodes) ? nodes : [nodes]) {
|
|
1821
|
-
const newNode = {
|
|
1822
|
-
...node,
|
|
1823
|
-
_resolver: loadResolver(await node._resolver)
|
|
1824
|
-
};
|
|
1825
|
-
graph.push(newNode);
|
|
1826
|
-
}
|
|
1827
|
-
tag.tagPosition = config.tagPosition === "head" ? "head" : "bodyClose";
|
|
1828
|
-
}
|
|
1829
|
-
if (tag.tag === "title")
|
|
1830
|
-
resolvedMeta.title = tag.textContent;
|
|
1831
|
-
else if (tag.tag === "meta" && tag.props.name === "description")
|
|
1832
|
-
resolvedMeta.description = tag.props.content;
|
|
1833
|
-
else if (tag.tag === "link" && tag.props.rel === "canonical")
|
|
1834
|
-
resolvedMeta.url = tag.props.href;
|
|
1835
|
-
else if (tag.tag === "meta" && tag.props.property === "og:image")
|
|
1836
|
-
resolvedMeta.image = tag.props.content;
|
|
1837
|
-
},
|
|
1838
|
-
"tags:resolve": async function(ctx) {
|
|
1839
|
-
for (const tag of ctx.tags) {
|
|
1840
|
-
if (tag.tag === "script" && tag.key === "schema-org-graph") {
|
|
1841
|
-
tag.innerHTML = JSON.stringify({
|
|
1842
|
-
"@context": "https://schema.org",
|
|
1843
|
-
"@graph": graph.resolveGraph({ ...config, ...resolvedMeta, ...await meta() })
|
|
1844
|
-
}, null, 2);
|
|
1845
|
-
delete tag.props.nodes;
|
|
1846
|
-
}
|
|
1847
|
-
}
|
|
1848
|
-
}
|
|
1849
|
-
}
|
|
1850
|
-
};
|
|
78
|
+
function defineVideo(input) {
|
|
79
|
+
return provideResolver(input, "video");
|
|
80
|
+
}
|
|
81
|
+
function defineWebPage(input) {
|
|
82
|
+
return provideResolver(input, "webPage");
|
|
83
|
+
}
|
|
84
|
+
function defineWebSite(input) {
|
|
85
|
+
return provideResolver(input, "webSite");
|
|
86
|
+
}
|
|
87
|
+
function defineBook(input) {
|
|
88
|
+
return provideResolver(input, "book");
|
|
89
|
+
}
|
|
90
|
+
function defineCourse(input) {
|
|
91
|
+
return provideResolver(input, "course");
|
|
92
|
+
}
|
|
93
|
+
function defineItemList(input) {
|
|
94
|
+
return provideResolver(input, "itemList");
|
|
95
|
+
}
|
|
96
|
+
function defineListItem(input) {
|
|
97
|
+
return provideResolver(input, "listItem");
|
|
98
|
+
}
|
|
99
|
+
function defineMovie(input) {
|
|
100
|
+
return provideResolver(input, "movie");
|
|
101
|
+
}
|
|
102
|
+
function defineSearchAction(input) {
|
|
103
|
+
return provideResolver(input, "searchAction");
|
|
104
|
+
}
|
|
105
|
+
function defineReadAction(input) {
|
|
106
|
+
return provideResolver(input, "readAction");
|
|
107
|
+
}
|
|
108
|
+
function defineSoftwareApp(input) {
|
|
109
|
+
return provideResolver(input, "softwareApp");
|
|
110
|
+
}
|
|
111
|
+
function defineBookEdition(input) {
|
|
112
|
+
return provideResolver(input, "bookEdition");
|
|
1851
113
|
}
|
|
1852
|
-
|
|
1853
|
-
const provideResolver = (input, resolver) => {
|
|
1854
|
-
if (!input)
|
|
1855
|
-
input = {};
|
|
1856
|
-
input._resolver = resolver;
|
|
1857
|
-
return input;
|
|
1858
|
-
};
|
|
1859
|
-
const defineAddress = (input) => provideResolver(input, "address");
|
|
1860
|
-
const defineAggregateOffer = (input) => provideResolver(input, "aggregateOffer");
|
|
1861
|
-
const defineAggregateRating = (input) => provideResolver(input, "aggregateRating");
|
|
1862
|
-
const defineArticle = (input) => provideResolver(input, "article");
|
|
1863
|
-
const defineBreadcrumb = (input) => provideResolver(input, "breadcrumb");
|
|
1864
|
-
const defineComment = (input) => provideResolver(input, "comment");
|
|
1865
|
-
const defineEvent = (input) => provideResolver(input, "event");
|
|
1866
|
-
const defineVirtualLocation = (input) => provideResolver(input, "virtualLocation");
|
|
1867
|
-
const definePlace = (input) => provideResolver(input, "place");
|
|
1868
|
-
const defineHowTo = (input) => provideResolver(input, "howTo");
|
|
1869
|
-
const defineHowToStep = (input) => provideResolver(input, "howToStep");
|
|
1870
|
-
const defineImage = (input) => provideResolver(input, "image");
|
|
1871
|
-
const defineJobPosting = (input) => provideResolver(input, "jobPosting");
|
|
1872
|
-
const defineLocalBusiness = (input) => provideResolver(input, "localBusiness");
|
|
1873
|
-
const defineOffer = (input) => provideResolver(input, "offer");
|
|
1874
|
-
const defineOpeningHours = (input) => provideResolver(input, "openingHours");
|
|
1875
|
-
const defineOrganization = (input) => provideResolver(input, "organization");
|
|
1876
|
-
const definePerson = (input) => provideResolver(input, "person");
|
|
1877
|
-
const defineProduct = (input) => provideResolver(input, "product");
|
|
1878
|
-
const defineQuestion = (input) => provideResolver(input, "question");
|
|
1879
|
-
const defineRecipe = (input) => provideResolver(input, "recipe");
|
|
1880
|
-
const defineReview = (input) => provideResolver(input, "review");
|
|
1881
|
-
const defineVideo = (input) => provideResolver(input, "video");
|
|
1882
|
-
const defineWebPage = (input) => provideResolver(input, "webPage");
|
|
1883
|
-
const defineWebSite = (input) => provideResolver(input, "webSite");
|
|
1884
|
-
const defineBook = (input) => provideResolver(input, "book");
|
|
1885
|
-
const defineCourse = (input) => provideResolver(input, "course");
|
|
1886
|
-
const defineItemList = (input) => provideResolver(input, "itemList");
|
|
1887
|
-
const defineListItem = (input) => provideResolver(input, "listItem");
|
|
1888
|
-
const defineMovie = (input) => provideResolver(input, "movie");
|
|
1889
|
-
const defineSearchAction = (input) => provideResolver(input, "searchAction");
|
|
1890
|
-
const defineReadAction = (input) => provideResolver(input, "readAction");
|
|
1891
|
-
const defineSoftwareApp = (input) => provideResolver(input, "softwareApp");
|
|
1892
|
-
const defineBookEdition = (input) => provideResolver(input, "bookEdition");
|
|
1893
114
|
function useSchemaOrg(input) {
|
|
1894
115
|
return useHead({
|
|
1895
116
|
script: [
|
|
@@ -1899,7 +120,7 @@ function useSchemaOrg(input) {
|
|
|
1899
120
|
nodes: input
|
|
1900
121
|
}
|
|
1901
122
|
]
|
|
1902
|
-
}
|
|
123
|
+
});
|
|
1903
124
|
}
|
|
1904
125
|
|
|
1905
|
-
export {
|
|
126
|
+
export { defineAddress, defineAggregateOffer, defineAggregateRating, defineArticle, defineBook, defineBookEdition, defineBreadcrumb, defineComment, defineCourse, defineEvent, defineHowTo, defineHowToStep, defineImage, defineItemList, defineJobPosting, defineListItem, defineLocalBusiness, defineMovie, defineOffer, defineOpeningHours, defineOrganization, definePerson, definePlace, defineProduct, defineQuestion, defineReadAction, defineRecipe, defineReview, defineSearchAction, defineSoftwareApp, defineVideo, defineVirtualLocation, defineWebPage, defineWebSite, useSchemaOrg };
|