@unhead/addons 1.11.15 → 2.0.0-alpha.1
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 +2 -67
- package/dist/index.d.cts +2 -24
- package/dist/index.d.mts +2 -24
- package/dist/index.d.ts +2 -24
- package/dist/index.mjs +2 -67
- package/dist/shared/{addons.CgcXPvGI.cjs → addons.By35C-fR.cjs} +2 -2
- package/dist/shared/{addons.BBC86_qB.mjs → addons.CmryBgzY.mjs} +2 -2
- package/dist/vite.cjs +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/webpack.cjs +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +9 -7
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const plugins = require('unhead/plugins');
|
|
4
4
|
|
|
5
5
|
const DefaultCriticalTags = {
|
|
6
6
|
htmlAttrs: {
|
|
@@ -12,70 +12,5 @@ const DefaultCriticalTags = {
|
|
|
12
12
|
]
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
function InferSeoMetaPlugin(options = {}) {
|
|
17
|
-
return shared.defineHeadPlugin({
|
|
18
|
-
hooks: {
|
|
19
|
-
entries: {
|
|
20
|
-
resolve({ entries }) {
|
|
21
|
-
let titleTemplate = null;
|
|
22
|
-
let lastWeight = 999;
|
|
23
|
-
for (const entry of entries) {
|
|
24
|
-
const inputKey = entry.resolvedInput ? "resolvedInput" : "input";
|
|
25
|
-
const input = entry[inputKey];
|
|
26
|
-
const weight = (typeof input.titleTemplate === "object" ? input.titleTemplate?.tagPriority : false) || entry.tagPriority || 100;
|
|
27
|
-
if (input.titleTemplate !== void 0 && weight <= lastWeight) {
|
|
28
|
-
titleTemplate = input.titleTemplate;
|
|
29
|
-
lastWeight = weight;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
for (const entry of entries) {
|
|
33
|
-
const inputKey = entry.resolvedInput ? "resolvedInput" : "input";
|
|
34
|
-
const input = entry[inputKey];
|
|
35
|
-
const resolvedMeta = input.meta || [];
|
|
36
|
-
titleTemplate = shared.resolveTitleTemplate(titleTemplate, input.title);
|
|
37
|
-
const title = input.title;
|
|
38
|
-
const description = resolvedMeta.find((meta) => meta.name === "description")?.content;
|
|
39
|
-
const hasOgTitle = resolvedMeta.some((meta) => meta.property === "og:title");
|
|
40
|
-
const hasOgImage = resolvedMeta.some((meta) => meta.property === "og:image");
|
|
41
|
-
const hasTwitterCard = resolvedMeta.some((meta) => meta.name === "twitter:card");
|
|
42
|
-
const hasOgDescription = resolvedMeta.some((meta) => meta.property === "og:description");
|
|
43
|
-
entry[inputKey].meta = input.meta || [];
|
|
44
|
-
if (!hasOgTitle && (input.titleTemplate || input.title)) {
|
|
45
|
-
let newOgTitle = options?.ogTitle || titleTemplate || input.title;
|
|
46
|
-
if (typeof newOgTitle === "function")
|
|
47
|
-
newOgTitle = newOgTitle(title);
|
|
48
|
-
if (newOgTitle) {
|
|
49
|
-
entry[inputKey].meta.push({
|
|
50
|
-
property: "og:title",
|
|
51
|
-
// have the og:title be removed if we don't have a title
|
|
52
|
-
content: String(newOgTitle)
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
if (description && !hasOgDescription) {
|
|
57
|
-
let newOgDescription = options?.ogDescription || description;
|
|
58
|
-
if (typeof newOgDescription === "function")
|
|
59
|
-
newOgDescription = newOgDescription(title);
|
|
60
|
-
if (newOgDescription) {
|
|
61
|
-
entry[inputKey].meta.push({
|
|
62
|
-
property: "og:description",
|
|
63
|
-
content: String(newOgDescription)
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
if (hasOgImage && !hasTwitterCard) {
|
|
68
|
-
entry[inputKey].meta.push({
|
|
69
|
-
name: "twitter:card",
|
|
70
|
-
content: options?.twitterCard || "summary_large_image"
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
|
|
15
|
+
exports.InferSeoMetaPlugin = plugins.InferSeoMetaPlugin;
|
|
80
16
|
exports.DefaultCriticalTags = DefaultCriticalTags;
|
|
81
|
-
exports.InferSeoMetaPlugin = InferSeoMetaPlugin;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
export { InferSeoMetaPlugin } from 'unhead/plugins';
|
|
2
2
|
|
|
3
3
|
declare const DefaultCriticalTags: {
|
|
4
4
|
htmlAttrs: {
|
|
@@ -15,26 +15,4 @@ declare const DefaultCriticalTags: {
|
|
|
15
15
|
})[];
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Transform the og title.
|
|
21
|
-
*
|
|
22
|
-
* @param title
|
|
23
|
-
*/
|
|
24
|
-
ogTitle?: ((title: string) => string);
|
|
25
|
-
/**
|
|
26
|
-
* Transform the og description.
|
|
27
|
-
*
|
|
28
|
-
* @param title
|
|
29
|
-
*/
|
|
30
|
-
ogDescription?: ((description: string) => string);
|
|
31
|
-
/**
|
|
32
|
-
* The twitter card to use.
|
|
33
|
-
*
|
|
34
|
-
* @default 'summary_large_image'
|
|
35
|
-
*/
|
|
36
|
-
twitterCard?: false | 'summary' | 'summary_large_image' | 'app' | 'player';
|
|
37
|
-
}
|
|
38
|
-
declare function InferSeoMetaPlugin(options?: InferSeoMetaPluginOptions): _unhead_schema.HeadPluginInput;
|
|
39
|
-
|
|
40
|
-
export { DefaultCriticalTags, InferSeoMetaPlugin, type InferSeoMetaPluginOptions };
|
|
18
|
+
export { DefaultCriticalTags };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
export { InferSeoMetaPlugin } from 'unhead/plugins';
|
|
2
2
|
|
|
3
3
|
declare const DefaultCriticalTags: {
|
|
4
4
|
htmlAttrs: {
|
|
@@ -15,26 +15,4 @@ declare const DefaultCriticalTags: {
|
|
|
15
15
|
})[];
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Transform the og title.
|
|
21
|
-
*
|
|
22
|
-
* @param title
|
|
23
|
-
*/
|
|
24
|
-
ogTitle?: ((title: string) => string);
|
|
25
|
-
/**
|
|
26
|
-
* Transform the og description.
|
|
27
|
-
*
|
|
28
|
-
* @param title
|
|
29
|
-
*/
|
|
30
|
-
ogDescription?: ((description: string) => string);
|
|
31
|
-
/**
|
|
32
|
-
* The twitter card to use.
|
|
33
|
-
*
|
|
34
|
-
* @default 'summary_large_image'
|
|
35
|
-
*/
|
|
36
|
-
twitterCard?: false | 'summary' | 'summary_large_image' | 'app' | 'player';
|
|
37
|
-
}
|
|
38
|
-
declare function InferSeoMetaPlugin(options?: InferSeoMetaPluginOptions): _unhead_schema.HeadPluginInput;
|
|
39
|
-
|
|
40
|
-
export { DefaultCriticalTags, InferSeoMetaPlugin, type InferSeoMetaPluginOptions };
|
|
18
|
+
export { DefaultCriticalTags };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
export { InferSeoMetaPlugin } from 'unhead/plugins';
|
|
2
2
|
|
|
3
3
|
declare const DefaultCriticalTags: {
|
|
4
4
|
htmlAttrs: {
|
|
@@ -15,26 +15,4 @@ declare const DefaultCriticalTags: {
|
|
|
15
15
|
})[];
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Transform the og title.
|
|
21
|
-
*
|
|
22
|
-
* @param title
|
|
23
|
-
*/
|
|
24
|
-
ogTitle?: ((title: string) => string);
|
|
25
|
-
/**
|
|
26
|
-
* Transform the og description.
|
|
27
|
-
*
|
|
28
|
-
* @param title
|
|
29
|
-
*/
|
|
30
|
-
ogDescription?: ((description: string) => string);
|
|
31
|
-
/**
|
|
32
|
-
* The twitter card to use.
|
|
33
|
-
*
|
|
34
|
-
* @default 'summary_large_image'
|
|
35
|
-
*/
|
|
36
|
-
twitterCard?: false | 'summary' | 'summary_large_image' | 'app' | 'player';
|
|
37
|
-
}
|
|
38
|
-
declare function InferSeoMetaPlugin(options?: InferSeoMetaPluginOptions): _unhead_schema.HeadPluginInput;
|
|
39
|
-
|
|
40
|
-
export { DefaultCriticalTags, InferSeoMetaPlugin, type InferSeoMetaPluginOptions };
|
|
18
|
+
export { DefaultCriticalTags };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
export { InferSeoMetaPlugin } from 'unhead/plugins';
|
|
2
2
|
|
|
3
3
|
const DefaultCriticalTags = {
|
|
4
4
|
htmlAttrs: {
|
|
@@ -10,69 +10,4 @@ const DefaultCriticalTags = {
|
|
|
10
10
|
]
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
function InferSeoMetaPlugin(options = {}) {
|
|
15
|
-
return defineHeadPlugin({
|
|
16
|
-
hooks: {
|
|
17
|
-
entries: {
|
|
18
|
-
resolve({ entries }) {
|
|
19
|
-
let titleTemplate = null;
|
|
20
|
-
let lastWeight = 999;
|
|
21
|
-
for (const entry of entries) {
|
|
22
|
-
const inputKey = entry.resolvedInput ? "resolvedInput" : "input";
|
|
23
|
-
const input = entry[inputKey];
|
|
24
|
-
const weight = (typeof input.titleTemplate === "object" ? input.titleTemplate?.tagPriority : false) || entry.tagPriority || 100;
|
|
25
|
-
if (input.titleTemplate !== void 0 && weight <= lastWeight) {
|
|
26
|
-
titleTemplate = input.titleTemplate;
|
|
27
|
-
lastWeight = weight;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
for (const entry of entries) {
|
|
31
|
-
const inputKey = entry.resolvedInput ? "resolvedInput" : "input";
|
|
32
|
-
const input = entry[inputKey];
|
|
33
|
-
const resolvedMeta = input.meta || [];
|
|
34
|
-
titleTemplate = resolveTitleTemplate(titleTemplate, input.title);
|
|
35
|
-
const title = input.title;
|
|
36
|
-
const description = resolvedMeta.find((meta) => meta.name === "description")?.content;
|
|
37
|
-
const hasOgTitle = resolvedMeta.some((meta) => meta.property === "og:title");
|
|
38
|
-
const hasOgImage = resolvedMeta.some((meta) => meta.property === "og:image");
|
|
39
|
-
const hasTwitterCard = resolvedMeta.some((meta) => meta.name === "twitter:card");
|
|
40
|
-
const hasOgDescription = resolvedMeta.some((meta) => meta.property === "og:description");
|
|
41
|
-
entry[inputKey].meta = input.meta || [];
|
|
42
|
-
if (!hasOgTitle && (input.titleTemplate || input.title)) {
|
|
43
|
-
let newOgTitle = options?.ogTitle || titleTemplate || input.title;
|
|
44
|
-
if (typeof newOgTitle === "function")
|
|
45
|
-
newOgTitle = newOgTitle(title);
|
|
46
|
-
if (newOgTitle) {
|
|
47
|
-
entry[inputKey].meta.push({
|
|
48
|
-
property: "og:title",
|
|
49
|
-
// have the og:title be removed if we don't have a title
|
|
50
|
-
content: String(newOgTitle)
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
if (description && !hasOgDescription) {
|
|
55
|
-
let newOgDescription = options?.ogDescription || description;
|
|
56
|
-
if (typeof newOgDescription === "function")
|
|
57
|
-
newOgDescription = newOgDescription(title);
|
|
58
|
-
if (newOgDescription) {
|
|
59
|
-
entry[inputKey].meta.push({
|
|
60
|
-
property: "og:description",
|
|
61
|
-
content: String(newOgDescription)
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
if (hasOgImage && !hasTwitterCard) {
|
|
66
|
-
entry[inputKey].meta.push({
|
|
67
|
-
name: "twitter:card",
|
|
68
|
-
content: options?.twitterCard || "summary_large_image"
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export { DefaultCriticalTags, InferSeoMetaPlugin };
|
|
13
|
+
export { DefaultCriticalTags };
|
|
@@ -23,7 +23,7 @@ function RemoveFunctions(functionNames) {
|
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
const TreeshakeServerComposables = unplugin.createUnplugin((options = {}) => {
|
|
26
|
-
options.enabled = options.enabled !==
|
|
26
|
+
options.enabled = options.enabled !== undefined ? options.enabled : true;
|
|
27
27
|
return {
|
|
28
28
|
name: "unhead:remove-server-composables",
|
|
29
29
|
enforce: "post",
|
|
@@ -62,7 +62,7 @@ const TreeshakeServerComposables = unplugin.createUnplugin((options = {}) => {
|
|
|
62
62
|
])
|
|
63
63
|
]
|
|
64
64
|
});
|
|
65
|
-
} catch
|
|
65
|
+
} catch {
|
|
66
66
|
}
|
|
67
67
|
return transformed;
|
|
68
68
|
},
|
|
@@ -17,7 +17,7 @@ function RemoveFunctions(functionNames) {
|
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
19
|
const TreeshakeServerComposables = createUnplugin((options = {}) => {
|
|
20
|
-
options.enabled = options.enabled !==
|
|
20
|
+
options.enabled = options.enabled !== undefined ? options.enabled : true;
|
|
21
21
|
return {
|
|
22
22
|
name: "unhead:remove-server-composables",
|
|
23
23
|
enforce: "post",
|
|
@@ -56,7 +56,7 @@ const TreeshakeServerComposables = createUnplugin((options = {}) => {
|
|
|
56
56
|
])
|
|
57
57
|
]
|
|
58
58
|
});
|
|
59
|
-
} catch
|
|
59
|
+
} catch {
|
|
60
60
|
}
|
|
61
61
|
return transformed;
|
|
62
62
|
},
|
package/dist/vite.cjs
CHANGED
package/dist/vite.mjs
CHANGED
package/dist/webpack.cjs
CHANGED
package/dist/webpack.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unhead/addons",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "2.0.0-alpha.1",
|
|
5
5
|
"author": "Harlan Wilton <harlan@harlanzw.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": "https://github.com/sponsors/harlan-zw",
|
|
@@ -48,23 +48,25 @@
|
|
|
48
48
|
"files": [
|
|
49
49
|
"dist"
|
|
50
50
|
],
|
|
51
|
+
"peerDependencies": {
|
|
52
|
+
"unhead": "2.0.0-alpha.1"
|
|
53
|
+
},
|
|
51
54
|
"dependencies": {
|
|
52
55
|
"@rollup/pluginutils": "^5.1.4",
|
|
53
56
|
"estree-walker": "^3.0.3",
|
|
54
57
|
"magic-string": "^0.30.17",
|
|
55
|
-
"mlly": "^1.7.
|
|
58
|
+
"mlly": "^1.7.4",
|
|
56
59
|
"ufo": "^1.5.4",
|
|
57
60
|
"unplugin": "^2.1.2",
|
|
58
61
|
"unplugin-ast": "^0.13.1",
|
|
59
|
-
"@unhead/schema": "
|
|
60
|
-
"@unhead/shared": "
|
|
62
|
+
"@unhead/schema": "2.0.0-alpha.1",
|
|
63
|
+
"@unhead/shared": "2.0.0-alpha.1"
|
|
61
64
|
},
|
|
62
65
|
"devDependencies": {
|
|
63
|
-
"@babel/types": "^7.26.
|
|
66
|
+
"@babel/types": "^7.26.5"
|
|
64
67
|
},
|
|
65
68
|
"scripts": {
|
|
66
69
|
"build": "unbuild .",
|
|
67
|
-
"stub": "unbuild . --stub"
|
|
68
|
-
"export:sizes": "npx export-size . -r"
|
|
70
|
+
"stub": "unbuild . --stub"
|
|
69
71
|
}
|
|
70
72
|
}
|