@unhead/vue 1.0.2 → 1.0.4
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 +8 -5
- package/dist/index.mjs +8 -5
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -44,6 +44,8 @@ const setAttrs = (ctx, markSideEffect) => {
|
|
|
44
44
|
value = String(value);
|
|
45
45
|
const attrSdeKey = `attr:${k}`;
|
|
46
46
|
if (k === "class") {
|
|
47
|
+
if (!value)
|
|
48
|
+
return;
|
|
47
49
|
for (const c of value.split(" ")) {
|
|
48
50
|
const classSdeKey = `${attrSdeKey}:${c}`;
|
|
49
51
|
if (markSideEffect)
|
|
@@ -324,7 +326,7 @@ const renderTitleTemplate = (template, title) => {
|
|
|
324
326
|
return template.replace("%s", title ?? "");
|
|
325
327
|
};
|
|
326
328
|
function resolveTitleTemplateFromTags(tags) {
|
|
327
|
-
|
|
329
|
+
let titleTemplateIdx = tags.findIndex((i) => i.tag === "titleTemplate");
|
|
328
330
|
const titleIdx = tags.findIndex((i) => i.tag === "title");
|
|
329
331
|
if (titleIdx !== -1 && titleTemplateIdx !== -1) {
|
|
330
332
|
const newTitle = renderTitleTemplate(
|
|
@@ -343,6 +345,7 @@ function resolveTitleTemplateFromTags(tags) {
|
|
|
343
345
|
if (newTitle !== null) {
|
|
344
346
|
tags[titleTemplateIdx].children = newTitle;
|
|
345
347
|
tags[titleTemplateIdx].tag = "title";
|
|
348
|
+
titleTemplateIdx = -1;
|
|
346
349
|
}
|
|
347
350
|
}
|
|
348
351
|
if (titleTemplateIdx !== -1) {
|
|
@@ -581,7 +584,7 @@ const TagEntityBits = 10;
|
|
|
581
584
|
|
|
582
585
|
async function normaliseEntryTags(e) {
|
|
583
586
|
const tagPromises = [];
|
|
584
|
-
Object.entries(e.input).filter(([k, v]) => typeof v !== "undefined" && ValidHeadTags.includes(k)).forEach(([k, value]) => {
|
|
587
|
+
Object.entries(e.resolvedInput || e.input).filter(([k, v]) => typeof v !== "undefined" && ValidHeadTags.includes(k)).forEach(([k, value]) => {
|
|
585
588
|
const v = asArray$1(value);
|
|
586
589
|
tagPromises.push(...v.map((props) => normaliseTag(k, props)).flat());
|
|
587
590
|
});
|
|
@@ -797,7 +800,7 @@ const VueReactiveUseHeadPlugin = () => {
|
|
|
797
800
|
hooks: {
|
|
798
801
|
"entries:resolve": function(ctx) {
|
|
799
802
|
for (const entry of ctx.entries)
|
|
800
|
-
entry.
|
|
803
|
+
entry.resolvedInput = resolveUnrefHeadInput(entry.input);
|
|
801
804
|
}
|
|
802
805
|
}
|
|
803
806
|
});
|
|
@@ -1008,10 +1011,10 @@ const useServerBodyAttrs = (attrs) => useHead({ bodyAttrs: attrs });
|
|
|
1008
1011
|
|
|
1009
1012
|
function useHead(input, options = {}) {
|
|
1010
1013
|
const head = injectHead();
|
|
1011
|
-
const isBrowser = IsBrowser || head.resolvedOptions?.document;
|
|
1014
|
+
const isBrowser = IsBrowser || !!head.resolvedOptions?.document;
|
|
1012
1015
|
if (options.mode === "server" && isBrowser || options.mode === "client" && !isBrowser)
|
|
1013
1016
|
return;
|
|
1014
|
-
return
|
|
1017
|
+
return isBrowser ? clientUseHead(input, options) : serverUseHead(input, options);
|
|
1015
1018
|
}
|
|
1016
1019
|
const useTagTitle = (title) => useHead({ title });
|
|
1017
1020
|
const useTitleTemplate = (titleTemplate) => useHead({ titleTemplate });
|
package/dist/index.mjs
CHANGED
|
@@ -42,6 +42,8 @@ const setAttrs = (ctx, markSideEffect) => {
|
|
|
42
42
|
value = String(value);
|
|
43
43
|
const attrSdeKey = `attr:${k}`;
|
|
44
44
|
if (k === "class") {
|
|
45
|
+
if (!value)
|
|
46
|
+
return;
|
|
45
47
|
for (const c of value.split(" ")) {
|
|
46
48
|
const classSdeKey = `${attrSdeKey}:${c}`;
|
|
47
49
|
if (markSideEffect)
|
|
@@ -322,7 +324,7 @@ const renderTitleTemplate = (template, title) => {
|
|
|
322
324
|
return template.replace("%s", title ?? "");
|
|
323
325
|
};
|
|
324
326
|
function resolveTitleTemplateFromTags(tags) {
|
|
325
|
-
|
|
327
|
+
let titleTemplateIdx = tags.findIndex((i) => i.tag === "titleTemplate");
|
|
326
328
|
const titleIdx = tags.findIndex((i) => i.tag === "title");
|
|
327
329
|
if (titleIdx !== -1 && titleTemplateIdx !== -1) {
|
|
328
330
|
const newTitle = renderTitleTemplate(
|
|
@@ -341,6 +343,7 @@ function resolveTitleTemplateFromTags(tags) {
|
|
|
341
343
|
if (newTitle !== null) {
|
|
342
344
|
tags[titleTemplateIdx].children = newTitle;
|
|
343
345
|
tags[titleTemplateIdx].tag = "title";
|
|
346
|
+
titleTemplateIdx = -1;
|
|
344
347
|
}
|
|
345
348
|
}
|
|
346
349
|
if (titleTemplateIdx !== -1) {
|
|
@@ -579,7 +582,7 @@ const TagEntityBits = 10;
|
|
|
579
582
|
|
|
580
583
|
async function normaliseEntryTags(e) {
|
|
581
584
|
const tagPromises = [];
|
|
582
|
-
Object.entries(e.input).filter(([k, v]) => typeof v !== "undefined" && ValidHeadTags.includes(k)).forEach(([k, value]) => {
|
|
585
|
+
Object.entries(e.resolvedInput || e.input).filter(([k, v]) => typeof v !== "undefined" && ValidHeadTags.includes(k)).forEach(([k, value]) => {
|
|
583
586
|
const v = asArray$1(value);
|
|
584
587
|
tagPromises.push(...v.map((props) => normaliseTag(k, props)).flat());
|
|
585
588
|
});
|
|
@@ -795,7 +798,7 @@ const VueReactiveUseHeadPlugin = () => {
|
|
|
795
798
|
hooks: {
|
|
796
799
|
"entries:resolve": function(ctx) {
|
|
797
800
|
for (const entry of ctx.entries)
|
|
798
|
-
entry.
|
|
801
|
+
entry.resolvedInput = resolveUnrefHeadInput(entry.input);
|
|
799
802
|
}
|
|
800
803
|
}
|
|
801
804
|
});
|
|
@@ -1006,10 +1009,10 @@ const useServerBodyAttrs = (attrs) => useHead({ bodyAttrs: attrs });
|
|
|
1006
1009
|
|
|
1007
1010
|
function useHead(input, options = {}) {
|
|
1008
1011
|
const head = injectHead();
|
|
1009
|
-
const isBrowser = IsBrowser || head.resolvedOptions?.document;
|
|
1012
|
+
const isBrowser = IsBrowser || !!head.resolvedOptions?.document;
|
|
1010
1013
|
if (options.mode === "server" && isBrowser || options.mode === "client" && !isBrowser)
|
|
1011
1014
|
return;
|
|
1012
|
-
return
|
|
1015
|
+
return isBrowser ? clientUseHead(input, options) : serverUseHead(input, options);
|
|
1013
1016
|
}
|
|
1014
1017
|
const useTagTitle = (title) => useHead({ title });
|
|
1015
1018
|
const useTitleTemplate = (titleTemplate) => useHead({ titleTemplate });
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unhead/vue",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
5
|
-
"packageManager": "pnpm@7.
|
|
4
|
+
"version": "1.0.4",
|
|
5
|
+
"packageManager": "pnpm@7.17.0",
|
|
6
6
|
"author": "Harlan Wilton <harlan@harlanzw.com>",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"funding": "https://github.com/sponsors/harlan-zw",
|
|
@@ -33,12 +33,12 @@
|
|
|
33
33
|
"vue": ">=2.7 || >=3"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"
|
|
37
|
-
"
|
|
36
|
+
"hookable": "^5.4.2",
|
|
37
|
+
"@unhead/schema": "1.0.4"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"
|
|
41
|
-
"
|
|
40
|
+
"vue": "^3.2.45",
|
|
41
|
+
"unhead": "1.0.4"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"build": "unbuild .",
|