@unhead/addons 1.0.1 → 1.0.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 +7 -4
- package/dist/index.mjs +7 -4
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -6,8 +6,10 @@ const InferSeoMetaPlugin = (options) => unhead.defineHeadPlugin({
|
|
|
6
6
|
hooks: {
|
|
7
7
|
tags: {
|
|
8
8
|
resolve(ctx) {
|
|
9
|
-
const
|
|
10
|
-
|
|
9
|
+
const tags = ctx.tags.reverse();
|
|
10
|
+
const title = tags.find((t) => t.tag === "title" && !!t.children);
|
|
11
|
+
const ogTitle = tags.find((t) => t.tag === "meta" && t.props.property === "og:title" && t._e === title?._e);
|
|
12
|
+
if (title && !ogTitle) {
|
|
11
13
|
ctx.tags.push({
|
|
12
14
|
_e: title._e,
|
|
13
15
|
tag: "meta",
|
|
@@ -18,7 +20,8 @@ const InferSeoMetaPlugin = (options) => unhead.defineHeadPlugin({
|
|
|
18
20
|
});
|
|
19
21
|
}
|
|
20
22
|
const description = ctx.tags.find((t) => t.tag === "meta" && t.props.name === "description" && !!t.props.content);
|
|
21
|
-
|
|
23
|
+
const ogDescription = tags.find((t) => t.tag === "meta" && t.props.property === "og:description" && t._e === description?._e);
|
|
24
|
+
if (description && !ogDescription) {
|
|
22
25
|
ctx.tags.push({
|
|
23
26
|
_e: description._e,
|
|
24
27
|
tag: "meta",
|
|
@@ -39,7 +42,7 @@ const InferSeoMetaPlugin = (options) => unhead.defineHeadPlugin({
|
|
|
39
42
|
}
|
|
40
43
|
});
|
|
41
44
|
}
|
|
42
|
-
if (options?.robots && !ctx.tags.find((t) => t.tag === "meta" && t.props.name === "robots")) {
|
|
45
|
+
if (options?.robots !== false && !ctx.tags.find((t) => t.tag === "meta" && t.props.name === "robots")) {
|
|
43
46
|
ctx.tags.push({
|
|
44
47
|
_e: ctx.tags[0]._e,
|
|
45
48
|
tag: "meta",
|
package/dist/index.mjs
CHANGED
|
@@ -4,8 +4,10 @@ const InferSeoMetaPlugin = (options) => defineHeadPlugin({
|
|
|
4
4
|
hooks: {
|
|
5
5
|
tags: {
|
|
6
6
|
resolve(ctx) {
|
|
7
|
-
const
|
|
8
|
-
|
|
7
|
+
const tags = ctx.tags.reverse();
|
|
8
|
+
const title = tags.find((t) => t.tag === "title" && !!t.children);
|
|
9
|
+
const ogTitle = tags.find((t) => t.tag === "meta" && t.props.property === "og:title" && t._e === title?._e);
|
|
10
|
+
if (title && !ogTitle) {
|
|
9
11
|
ctx.tags.push({
|
|
10
12
|
_e: title._e,
|
|
11
13
|
tag: "meta",
|
|
@@ -16,7 +18,8 @@ const InferSeoMetaPlugin = (options) => defineHeadPlugin({
|
|
|
16
18
|
});
|
|
17
19
|
}
|
|
18
20
|
const description = ctx.tags.find((t) => t.tag === "meta" && t.props.name === "description" && !!t.props.content);
|
|
19
|
-
|
|
21
|
+
const ogDescription = tags.find((t) => t.tag === "meta" && t.props.property === "og:description" && t._e === description?._e);
|
|
22
|
+
if (description && !ogDescription) {
|
|
20
23
|
ctx.tags.push({
|
|
21
24
|
_e: description._e,
|
|
22
25
|
tag: "meta",
|
|
@@ -37,7 +40,7 @@ const InferSeoMetaPlugin = (options) => defineHeadPlugin({
|
|
|
37
40
|
}
|
|
38
41
|
});
|
|
39
42
|
}
|
|
40
|
-
if (options?.robots && !ctx.tags.find((t) => t.tag === "meta" && t.props.name === "robots")) {
|
|
43
|
+
if (options?.robots !== false && !ctx.tags.find((t) => t.tag === "meta" && t.props.name === "robots")) {
|
|
41
44
|
ctx.tags.push({
|
|
42
45
|
_e: ctx.tags[0]._e,
|
|
43
46
|
tag: "meta",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unhead/addons",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.2",
|
|
5
5
|
"packageManager": "pnpm@7.14.0",
|
|
6
6
|
"author": "Harlan Wilton <harlan@harlanzw.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -51,14 +51,14 @@
|
|
|
51
51
|
],
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@rollup/pluginutils": "^5.0.2",
|
|
54
|
-
"@unhead/schema": "1.0.
|
|
55
|
-
"unhead": "1.0.
|
|
54
|
+
"@unhead/schema": "1.0.2",
|
|
55
|
+
"unhead": "1.0.2",
|
|
56
56
|
"unplugin": "^1.0.0",
|
|
57
57
|
"unplugin-ast": "^0.5.5"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@babel/types": "^7.20.2",
|
|
61
|
-
"zhead": "^1.0.
|
|
61
|
+
"zhead": "^1.0.3"
|
|
62
62
|
},
|
|
63
63
|
"scripts": {
|
|
64
64
|
"build": "unbuild .",
|