@unhead/schema-org 1.10.4 → 1.11.0-beta.2
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 +1 -1
- package/dist/index.d.cts +10 -10
- package/dist/index.d.mts +10 -10
- package/dist/index.d.ts +10 -10
- package/dist/index.mjs +2 -2
- package/dist/shared/{schema-org.967f487d.mjs → schema-org.7698b7cd.mjs} +118 -111
- package/dist/shared/{schema-org.b49caaf3.cjs → schema-org.99ac1ebf.cjs} +117 -110
- package/dist/shared/{schema-org.397d7cf9.d.cts → schema-org.d2b719c3.d.cts} +162 -154
- package/dist/shared/{schema-org.397d7cf9.d.mts → schema-org.d2b719c3.d.mts} +162 -154
- package/dist/shared/{schema-org.397d7cf9.d.ts → schema-org.d2b719c3.d.ts} +162 -154
- package/dist/vue.cjs +87 -88
- package/dist/vue.d.cts +30 -30
- package/dist/vue.d.mts +30 -30
- package/dist/vue.d.ts +30 -30
- package/dist/vue.mjs +85 -86
- package/package.json +6 -5
|
@@ -58,7 +58,7 @@ function dedupeMerge(node, field, value) {
|
|
|
58
58
|
function prefixId(url, id) {
|
|
59
59
|
if (ufo.hasProtocol(id))
|
|
60
60
|
return id;
|
|
61
|
-
if (id
|
|
61
|
+
if (!id.includes("#"))
|
|
62
62
|
id = `#${id}`;
|
|
63
63
|
return ufo.withBase(id, url);
|
|
64
64
|
}
|
|
@@ -228,59 +228,6 @@ const aggregateRatingResolver = defineSchemaOrgResolver({
|
|
|
228
228
|
}
|
|
229
229
|
});
|
|
230
230
|
|
|
231
|
-
const searchActionResolver = defineSchemaOrgResolver({
|
|
232
|
-
defaults: {
|
|
233
|
-
"@type": "SearchAction",
|
|
234
|
-
"target": {
|
|
235
|
-
"@type": "EntryPoint"
|
|
236
|
-
},
|
|
237
|
-
"query-input": {
|
|
238
|
-
"@type": "PropertyValueSpecification",
|
|
239
|
-
"valueRequired": true,
|
|
240
|
-
"valueName": "search_term_string"
|
|
241
|
-
}
|
|
242
|
-
},
|
|
243
|
-
resolve(node, ctx) {
|
|
244
|
-
if (typeof node.target === "string") {
|
|
245
|
-
node.target = {
|
|
246
|
-
"@type": "EntryPoint",
|
|
247
|
-
"urlTemplate": resolveWithBase(ctx.meta.host, node.target)
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
|
-
return node;
|
|
251
|
-
}
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
const PrimaryWebSiteId = "#website";
|
|
255
|
-
const webSiteResolver = defineSchemaOrgResolver({
|
|
256
|
-
defaults: {
|
|
257
|
-
"@type": "WebSite"
|
|
258
|
-
},
|
|
259
|
-
inheritMeta: [
|
|
260
|
-
"inLanguage",
|
|
261
|
-
{ meta: "host", key: "url" }
|
|
262
|
-
],
|
|
263
|
-
idPrefix: ["host", PrimaryWebSiteId],
|
|
264
|
-
resolve(node, ctx) {
|
|
265
|
-
node.potentialAction = resolveRelation(node.potentialAction, ctx, searchActionResolver, {
|
|
266
|
-
array: true
|
|
267
|
-
});
|
|
268
|
-
node.publisher = resolveRelation(node.publisher, ctx);
|
|
269
|
-
return node;
|
|
270
|
-
},
|
|
271
|
-
resolveRootNode(node, { find }) {
|
|
272
|
-
if (resolveAsGraphKey(node["@id"]) === PrimaryWebSiteId) {
|
|
273
|
-
const identity = find(IdentityId);
|
|
274
|
-
if (identity)
|
|
275
|
-
setIfEmpty(node, "publisher", idReference(identity));
|
|
276
|
-
const webPage = find(PrimaryWebPageId);
|
|
277
|
-
if (webPage)
|
|
278
|
-
setIfEmpty(webPage, "isPartOf", idReference(node));
|
|
279
|
-
}
|
|
280
|
-
return node;
|
|
281
|
-
}
|
|
282
|
-
});
|
|
283
|
-
|
|
284
231
|
const listItemResolver = defineSchemaOrgResolver({
|
|
285
232
|
cast(node) {
|
|
286
233
|
if (typeof node === "string") {
|
|
@@ -362,6 +309,59 @@ const addressResolver = defineSchemaOrgResolver({
|
|
|
362
309
|
}
|
|
363
310
|
});
|
|
364
311
|
|
|
312
|
+
const searchActionResolver = defineSchemaOrgResolver({
|
|
313
|
+
defaults: {
|
|
314
|
+
"@type": "SearchAction",
|
|
315
|
+
"target": {
|
|
316
|
+
"@type": "EntryPoint"
|
|
317
|
+
},
|
|
318
|
+
"query-input": {
|
|
319
|
+
"@type": "PropertyValueSpecification",
|
|
320
|
+
"valueRequired": true,
|
|
321
|
+
"valueName": "search_term_string"
|
|
322
|
+
}
|
|
323
|
+
},
|
|
324
|
+
resolve(node, ctx) {
|
|
325
|
+
if (typeof node.target === "string") {
|
|
326
|
+
node.target = {
|
|
327
|
+
"@type": "EntryPoint",
|
|
328
|
+
"urlTemplate": resolveWithBase(ctx.meta.host, node.target)
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
return node;
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
const PrimaryWebSiteId = "#website";
|
|
336
|
+
const webSiteResolver = defineSchemaOrgResolver({
|
|
337
|
+
defaults: {
|
|
338
|
+
"@type": "WebSite"
|
|
339
|
+
},
|
|
340
|
+
inheritMeta: [
|
|
341
|
+
"inLanguage",
|
|
342
|
+
{ meta: "host", key: "url" }
|
|
343
|
+
],
|
|
344
|
+
idPrefix: ["host", PrimaryWebSiteId],
|
|
345
|
+
resolve(node, ctx) {
|
|
346
|
+
node.potentialAction = resolveRelation(node.potentialAction, ctx, searchActionResolver, {
|
|
347
|
+
array: true
|
|
348
|
+
});
|
|
349
|
+
node.publisher = resolveRelation(node.publisher, ctx);
|
|
350
|
+
return node;
|
|
351
|
+
},
|
|
352
|
+
resolveRootNode(node, { find }) {
|
|
353
|
+
if (resolveAsGraphKey(node["@id"]) === PrimaryWebSiteId) {
|
|
354
|
+
const identity = find(IdentityId);
|
|
355
|
+
if (identity)
|
|
356
|
+
setIfEmpty(node, "publisher", idReference(identity));
|
|
357
|
+
const webPage = find(PrimaryWebPageId);
|
|
358
|
+
if (webPage)
|
|
359
|
+
setIfEmpty(webPage, "isPartOf", idReference(node));
|
|
360
|
+
}
|
|
361
|
+
return node;
|
|
362
|
+
}
|
|
363
|
+
});
|
|
364
|
+
|
|
365
365
|
const organizationResolver = defineSchemaOrgResolver({
|
|
366
366
|
defaults: {
|
|
367
367
|
"@type": "Organization"
|
|
@@ -415,40 +415,6 @@ const organizationResolver = defineSchemaOrgResolver({
|
|
|
415
415
|
}
|
|
416
416
|
});
|
|
417
417
|
|
|
418
|
-
const personResolver = defineSchemaOrgResolver({
|
|
419
|
-
cast(node) {
|
|
420
|
-
if (typeof node === "string") {
|
|
421
|
-
return {
|
|
422
|
-
name: node
|
|
423
|
-
};
|
|
424
|
-
}
|
|
425
|
-
return node;
|
|
426
|
-
},
|
|
427
|
-
defaults: {
|
|
428
|
-
"@type": "Person"
|
|
429
|
-
},
|
|
430
|
-
idPrefix: ["host", IdentityId],
|
|
431
|
-
resolve(node, ctx) {
|
|
432
|
-
if (node.url)
|
|
433
|
-
node.url = resolveWithBase(ctx.meta.host, node.url);
|
|
434
|
-
return node;
|
|
435
|
-
},
|
|
436
|
-
resolveRootNode(node, { find, meta }) {
|
|
437
|
-
if (resolveAsGraphKey(node["@id"]) === IdentityId) {
|
|
438
|
-
setIfEmpty(node, "url", meta.host);
|
|
439
|
-
const webPage = find(PrimaryWebPageId);
|
|
440
|
-
if (webPage)
|
|
441
|
-
setIfEmpty(webPage, "about", idReference(node));
|
|
442
|
-
const webSite = find(PrimaryWebSiteId);
|
|
443
|
-
if (webSite)
|
|
444
|
-
setIfEmpty(webSite, "publisher", idReference(node));
|
|
445
|
-
}
|
|
446
|
-
const article = find(PrimaryArticleId);
|
|
447
|
-
if (article)
|
|
448
|
-
setIfEmpty(article, "author", idReference(node));
|
|
449
|
-
}
|
|
450
|
-
});
|
|
451
|
-
|
|
452
418
|
const readActionResolver = defineSchemaOrgResolver({
|
|
453
419
|
defaults: {
|
|
454
420
|
"@type": "ReadAction"
|
|
@@ -534,6 +500,40 @@ const webPageResolver = defineSchemaOrgResolver({
|
|
|
534
500
|
}
|
|
535
501
|
});
|
|
536
502
|
|
|
503
|
+
const personResolver = defineSchemaOrgResolver({
|
|
504
|
+
cast(node) {
|
|
505
|
+
if (typeof node === "string") {
|
|
506
|
+
return {
|
|
507
|
+
name: node
|
|
508
|
+
};
|
|
509
|
+
}
|
|
510
|
+
return node;
|
|
511
|
+
},
|
|
512
|
+
defaults: {
|
|
513
|
+
"@type": "Person"
|
|
514
|
+
},
|
|
515
|
+
idPrefix: ["host", IdentityId],
|
|
516
|
+
resolve(node, ctx) {
|
|
517
|
+
if (node.url)
|
|
518
|
+
node.url = resolveWithBase(ctx.meta.host, node.url);
|
|
519
|
+
return node;
|
|
520
|
+
},
|
|
521
|
+
resolveRootNode(node, { find, meta }) {
|
|
522
|
+
if (resolveAsGraphKey(node["@id"]) === IdentityId) {
|
|
523
|
+
setIfEmpty(node, "url", meta.host);
|
|
524
|
+
const webPage = find(PrimaryWebPageId);
|
|
525
|
+
if (webPage)
|
|
526
|
+
setIfEmpty(webPage, "about", idReference(node));
|
|
527
|
+
const webSite = find(PrimaryWebSiteId);
|
|
528
|
+
if (webSite)
|
|
529
|
+
setIfEmpty(webSite, "publisher", idReference(node));
|
|
530
|
+
}
|
|
531
|
+
const article = find(PrimaryArticleId);
|
|
532
|
+
if (article)
|
|
533
|
+
setIfEmpty(article, "author", idReference(node));
|
|
534
|
+
}
|
|
535
|
+
});
|
|
536
|
+
|
|
537
537
|
const PrimaryArticleId = "#article";
|
|
538
538
|
const articleResolver = defineSchemaOrgResolver({
|
|
539
539
|
defaults: {
|
|
@@ -746,22 +746,6 @@ const eventResolver = defineSchemaOrgResolver({
|
|
|
746
746
|
}
|
|
747
747
|
});
|
|
748
748
|
|
|
749
|
-
const ratingResolver = defineSchemaOrgResolver({
|
|
750
|
-
cast(node) {
|
|
751
|
-
if (node === "number") {
|
|
752
|
-
return {
|
|
753
|
-
ratingValue: node
|
|
754
|
-
};
|
|
755
|
-
}
|
|
756
|
-
return node;
|
|
757
|
-
},
|
|
758
|
-
defaults: {
|
|
759
|
-
"@type": "Rating",
|
|
760
|
-
"bestRating": 5,
|
|
761
|
-
"worstRating": 1
|
|
762
|
-
}
|
|
763
|
-
});
|
|
764
|
-
|
|
765
749
|
const openingHoursResolver = defineSchemaOrgResolver({
|
|
766
750
|
defaults: {
|
|
767
751
|
"@type": "OpeningHoursSpecification",
|
|
@@ -792,6 +776,22 @@ const localBusinessResolver = defineSchemaOrgResolver({
|
|
|
792
776
|
}
|
|
793
777
|
});
|
|
794
778
|
|
|
779
|
+
const ratingResolver = defineSchemaOrgResolver({
|
|
780
|
+
cast(node) {
|
|
781
|
+
if (node === "number") {
|
|
782
|
+
return {
|
|
783
|
+
ratingValue: node
|
|
784
|
+
};
|
|
785
|
+
}
|
|
786
|
+
return node;
|
|
787
|
+
},
|
|
788
|
+
defaults: {
|
|
789
|
+
"@type": "Rating",
|
|
790
|
+
"bestRating": 5,
|
|
791
|
+
"worstRating": 1
|
|
792
|
+
}
|
|
793
|
+
});
|
|
794
|
+
|
|
795
795
|
const foodEstablishmentResolver = defineSchemaOrgResolver({
|
|
796
796
|
defaults: {
|
|
797
797
|
"@type": ["Organization", "LocalBusiness", "FoodEstablishment"]
|
|
@@ -1912,13 +1912,13 @@ function resolveNode(node, ctx, resolver) {
|
|
|
1912
1912
|
function resolveNodeId(node, ctx, resolver, resolveAsRoot = false) {
|
|
1913
1913
|
if (node["@id"] && node["@id"].startsWith("http"))
|
|
1914
1914
|
return node;
|
|
1915
|
-
const prefix = (Array.isArray(resolver.idPrefix) ? resolver.idPrefix[0] : resolver.idPrefix) || "url";
|
|
1916
|
-
const rootId = node["@id"] || (Array.isArray(resolver.idPrefix) ? resolver.idPrefix?.[1] : void 0);
|
|
1915
|
+
const prefix = resolver ? (Array.isArray(resolver.idPrefix) ? resolver.idPrefix[0] : resolver.idPrefix) || "url" : "url";
|
|
1916
|
+
const rootId = node["@id"] || (resolver ? Array.isArray(resolver.idPrefix) ? resolver.idPrefix?.[1] : void 0 : "");
|
|
1917
1917
|
if (!node["@id"] && resolveAsRoot && rootId) {
|
|
1918
1918
|
node["@id"] = prefixId(ctx.meta[prefix], rootId);
|
|
1919
1919
|
return node;
|
|
1920
1920
|
}
|
|
1921
|
-
if (node["@id"]?.startsWith("#/schema/")) {
|
|
1921
|
+
if (node["@id"]?.startsWith("#/schema/") || node["@id"]?.startsWith("/")) {
|
|
1922
1922
|
node["@id"] = prefixId(ctx.meta[prefix], node["@id"]);
|
|
1923
1923
|
return node;
|
|
1924
1924
|
}
|
|
@@ -1946,10 +1946,10 @@ function resolveRelation(input, ctx, fallbackResolver, options = {}) {
|
|
|
1946
1946
|
const ids = asArray(input).map((a) => {
|
|
1947
1947
|
const keys = Object.keys(a).length;
|
|
1948
1948
|
if (keys === 1 && a["@id"] || keys === 2 && a["@id"] && a["@type"]) {
|
|
1949
|
-
return {
|
|
1949
|
+
return resolveNodeId({
|
|
1950
1950
|
// we drop @type
|
|
1951
1951
|
"@id": ctx.find(a["@id"])?.["@id"] || a["@id"]
|
|
1952
|
-
};
|
|
1952
|
+
}, ctx);
|
|
1953
1953
|
}
|
|
1954
1954
|
let resolver = fallbackResolver;
|
|
1955
1955
|
if (a._resolver) {
|
|
@@ -2094,6 +2094,10 @@ function normaliseNodes(nodes) {
|
|
|
2094
2094
|
return Object.values(dedupedNodes);
|
|
2095
2095
|
}
|
|
2096
2096
|
|
|
2097
|
+
const baseRelationNodes = [
|
|
2098
|
+
"translationOfWork",
|
|
2099
|
+
"workTranslation"
|
|
2100
|
+
];
|
|
2097
2101
|
function createSchemaOrgGraph() {
|
|
2098
2102
|
const ctx = {
|
|
2099
2103
|
find(id) {
|
|
@@ -2123,6 +2127,9 @@ function createSchemaOrgGraph() {
|
|
|
2123
2127
|
root: true
|
|
2124
2128
|
});
|
|
2125
2129
|
}
|
|
2130
|
+
baseRelationNodes.forEach((k) => {
|
|
2131
|
+
node[k] = resolveRelation(node[k], ctx);
|
|
2132
|
+
});
|
|
2126
2133
|
if (node._resolver?.resolveRootNode)
|
|
2127
2134
|
node._resolver.resolveRootNode(node, ctx);
|
|
2128
2135
|
delete node._resolver;
|
|
@@ -2153,7 +2160,7 @@ function SchemaOrgUnheadPlugin(config, meta, options) {
|
|
|
2153
2160
|
graph = createSchemaOrgGraph();
|
|
2154
2161
|
},
|
|
2155
2162
|
"tag:normalise": async ({ tag }) => {
|
|
2156
|
-
if (tag.key === "schema-org-graph") {
|
|
2163
|
+
if (tag.key === "schema-org-graph" || tag.props.id === "schema-org-graph") {
|
|
2157
2164
|
const { loadResolver } = await Promise.resolve().then(function () { return resolver; });
|
|
2158
2165
|
const nodes = await tag.props.nodes;
|
|
2159
2166
|
for (const node of Array.isArray(nodes) ? nodes : [nodes]) {
|