@kimesh/head 0.2.35 → 0.2.36
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/plugin.mjs +15 -10
- package/package.json +3 -3
package/dist/plugin.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineKimeshRuntimePlugin } from "@kimesh/router-runtime";
|
|
1
|
+
import { createLoaderDataKey, defineKimeshRuntimePlugin } from "@kimesh/router-runtime";
|
|
2
2
|
import { createHead, renderDOMHead } from "@unhead/vue/client";
|
|
3
3
|
import { nextTick } from "vue";
|
|
4
4
|
|
|
@@ -12,17 +12,22 @@ const KIMESH_HEAD_KEY = Symbol("kimesh:head");
|
|
|
12
12
|
/**
|
|
13
13
|
* Get merged head configuration from matched routes
|
|
14
14
|
*/
|
|
15
|
-
function getRouteHead(route) {
|
|
15
|
+
function getRouteHead(route, kimeshApp) {
|
|
16
16
|
const heads = [];
|
|
17
17
|
for (const record of route.matched) {
|
|
18
18
|
const routeDef = record.meta?.__kimesh;
|
|
19
|
-
if (!routeDef
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
if (!routeDef) continue;
|
|
20
|
+
let headConfig;
|
|
21
|
+
if (routeDef.head) {
|
|
22
|
+
const loaderDataKey = createLoaderDataKey(record.path);
|
|
23
|
+
const loaderData = kimeshApp._state[loaderDataKey];
|
|
24
|
+
headConfig = typeof routeDef.head === "function" ? routeDef.head({
|
|
25
|
+
params: route.params,
|
|
26
|
+
loaderData,
|
|
27
|
+
route
|
|
28
|
+
}) : routeDef.head;
|
|
29
|
+
} else if (routeDef.meta?.title) headConfig = { title: routeDef.meta.title };
|
|
30
|
+
if (headConfig) heads.push(headConfig);
|
|
26
31
|
}
|
|
27
32
|
if (heads.length === 0) return void 0;
|
|
28
33
|
return heads.reduce((merged, head) => ({
|
|
@@ -54,7 +59,7 @@ const KimeshHeadPlugin = defineKimeshRuntimePlugin({
|
|
|
54
59
|
routeHeadEntry.dispose();
|
|
55
60
|
routeHeadEntry = null;
|
|
56
61
|
}
|
|
57
|
-
const routeHead = getRouteHead(to);
|
|
62
|
+
const routeHead = getRouteHead(to, app);
|
|
58
63
|
if (routeHead) routeHeadEntry = head.push(routeHead);
|
|
59
64
|
nextTick(() => {
|
|
60
65
|
renderDOMHead(head);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kimesh/head",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.36",
|
|
4
4
|
"description": "Head meta management for Kimesh framework",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@unhead/vue": "^2.0.8"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@kimesh/router-runtime": "0.2.
|
|
40
|
+
"@kimesh/router-runtime": "0.2.36",
|
|
41
41
|
"@types/node": "^25.0.8",
|
|
42
42
|
"@vue/test-utils": "^2.4.6",
|
|
43
43
|
"jsdom": "^27.4.0",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"vue-tsc": "^3.2.2"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"@kimesh/router-runtime": "0.2.
|
|
52
|
+
"@kimesh/router-runtime": "0.2.36",
|
|
53
53
|
"vue": "^3.5.0"
|
|
54
54
|
}
|
|
55
55
|
}
|