@unhead/schema-org 0.4.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +14 -7
- package/dist/index.mjs +14 -7
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -6,10 +6,17 @@ function defineSchemaOrgResolver(schema) {
|
|
|
6
6
|
return schema;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
const PROTOCOL_STRICT_REGEX = /^\w{2,}:([/\\]{1,2})/;
|
|
10
|
+
const PROTOCOL_REGEX = /^\w{2,}:([/\\]{2})?/;
|
|
11
|
+
const PROTOCOL_RELATIVE_REGEX = /^[/\\]{2}[^/\\]+/;
|
|
12
|
+
function hasProtocol(inputString, opts = {}) {
|
|
13
|
+
if (typeof opts === "boolean") {
|
|
14
|
+
opts = { acceptRelative: opts };
|
|
15
|
+
}
|
|
16
|
+
if (opts.strict) {
|
|
17
|
+
return PROTOCOL_STRICT_REGEX.test(inputString);
|
|
18
|
+
}
|
|
19
|
+
return PROTOCOL_REGEX.test(inputString) || (opts.acceptRelative ? PROTOCOL_RELATIVE_REGEX.test(inputString) : false);
|
|
13
20
|
}
|
|
14
21
|
const TRAILING_SLASH_RE = /\/$|\/\?/;
|
|
15
22
|
function hasTrailingSlash(input = "", queryParameters = false) {
|
|
@@ -176,7 +183,7 @@ const offerResolver = defineSchemaOrgResolver({
|
|
|
176
183
|
},
|
|
177
184
|
resolve(node, ctx) {
|
|
178
185
|
setIfEmpty(node, "priceCurrency", ctx.meta.currency);
|
|
179
|
-
setIfEmpty(node, "priceValidUntil", new Date(Date.UTC(new Date().getFullYear() + 1, 12, -1, 0, 0, 0)));
|
|
186
|
+
setIfEmpty(node, "priceValidUntil", new Date(Date.UTC((/* @__PURE__ */ new Date()).getFullYear() + 1, 12, -1, 0, 0, 0)));
|
|
180
187
|
if (node.url)
|
|
181
188
|
resolveWithBase(ctx.meta.host, node.url);
|
|
182
189
|
if (node.availability)
|
|
@@ -1822,7 +1829,7 @@ function SchemaOrgUnheadPlugin(config, meta) {
|
|
|
1822
1829
|
tag.tagPosition = config.tagPosition === "head" ? "head" : "bodyClose";
|
|
1823
1830
|
}
|
|
1824
1831
|
if (tag.tag === "title")
|
|
1825
|
-
resolvedMeta.title = tag.
|
|
1832
|
+
resolvedMeta.title = tag.textContent;
|
|
1826
1833
|
else if (tag.tag === "meta" && tag.props.name === "description")
|
|
1827
1834
|
resolvedMeta.description = tag.props.content;
|
|
1828
1835
|
else if (tag.tag === "link" && tag.props.rel === "canonical")
|
|
@@ -1833,7 +1840,7 @@ function SchemaOrgUnheadPlugin(config, meta) {
|
|
|
1833
1840
|
"tags:resolve": async function(ctx) {
|
|
1834
1841
|
for (const tag of ctx.tags) {
|
|
1835
1842
|
if (tag.tag === "script" && tag.key === "schema-org-graph") {
|
|
1836
|
-
tag.
|
|
1843
|
+
tag.innerHTML = JSON.stringify({
|
|
1837
1844
|
"@context": "https://schema.org",
|
|
1838
1845
|
"@graph": graph.resolveGraph({ ...config, ...resolvedMeta, ...await meta() })
|
|
1839
1846
|
}, null, 2);
|
package/dist/index.mjs
CHANGED
|
@@ -4,10 +4,17 @@ function defineSchemaOrgResolver(schema) {
|
|
|
4
4
|
return schema;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
const PROTOCOL_STRICT_REGEX = /^\w{2,}:([/\\]{1,2})/;
|
|
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);
|
|
11
18
|
}
|
|
12
19
|
const TRAILING_SLASH_RE = /\/$|\/\?/;
|
|
13
20
|
function hasTrailingSlash(input = "", queryParameters = false) {
|
|
@@ -174,7 +181,7 @@ const offerResolver = defineSchemaOrgResolver({
|
|
|
174
181
|
},
|
|
175
182
|
resolve(node, ctx) {
|
|
176
183
|
setIfEmpty(node, "priceCurrency", ctx.meta.currency);
|
|
177
|
-
setIfEmpty(node, "priceValidUntil", new Date(Date.UTC(new Date().getFullYear() + 1, 12, -1, 0, 0, 0)));
|
|
184
|
+
setIfEmpty(node, "priceValidUntil", new Date(Date.UTC((/* @__PURE__ */ new Date()).getFullYear() + 1, 12, -1, 0, 0, 0)));
|
|
178
185
|
if (node.url)
|
|
179
186
|
resolveWithBase(ctx.meta.host, node.url);
|
|
180
187
|
if (node.availability)
|
|
@@ -1820,7 +1827,7 @@ function SchemaOrgUnheadPlugin(config, meta) {
|
|
|
1820
1827
|
tag.tagPosition = config.tagPosition === "head" ? "head" : "bodyClose";
|
|
1821
1828
|
}
|
|
1822
1829
|
if (tag.tag === "title")
|
|
1823
|
-
resolvedMeta.title = tag.
|
|
1830
|
+
resolvedMeta.title = tag.textContent;
|
|
1824
1831
|
else if (tag.tag === "meta" && tag.props.name === "description")
|
|
1825
1832
|
resolvedMeta.description = tag.props.content;
|
|
1826
1833
|
else if (tag.tag === "link" && tag.props.rel === "canonical")
|
|
@@ -1831,7 +1838,7 @@ function SchemaOrgUnheadPlugin(config, meta) {
|
|
|
1831
1838
|
"tags:resolve": async function(ctx) {
|
|
1832
1839
|
for (const tag of ctx.tags) {
|
|
1833
1840
|
if (tag.tag === "script" && tag.key === "schema-org-graph") {
|
|
1834
|
-
tag.
|
|
1841
|
+
tag.innerHTML = JSON.stringify({
|
|
1835
1842
|
"@context": "https://schema.org",
|
|
1836
1843
|
"@graph": graph.resolveGraph({ ...config, ...resolvedMeta, ...await meta() })
|
|
1837
1844
|
}, null, 2);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unhead/schema-org",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"packageManager": "pnpm@7.8.0",
|
|
5
5
|
"description": "Node Schema.org for Simple and Automated Google Rich Results",
|
|
6
6
|
"author": "Harlan Wilton <harlan@harlanzw.com>",
|
|
@@ -34,11 +34,11 @@
|
|
|
34
34
|
"dist"
|
|
35
35
|
],
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"unhead": ">=1.
|
|
37
|
+
"unhead": ">=1.1.9"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"ufo": "^1.0
|
|
41
|
-
"unhead": "^1.
|
|
40
|
+
"ufo": "^1.1.0",
|
|
41
|
+
"unhead": "^1.1.9"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"build": "unbuild .",
|