@monkeyplus/flow 5.0.0-rc.102 → 5.0.0-rc.104
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/chunks/index.mjs
CHANGED
|
@@ -24,7 +24,7 @@ import replace from '@rollup/plugin-replace';
|
|
|
24
24
|
import { sanitizeFilePath } from 'mlly';
|
|
25
25
|
import { resolveTSConfig } from 'pkg-types';
|
|
26
26
|
|
|
27
|
-
const version = "5.0.0-rc.
|
|
27
|
+
const version = "5.0.0-rc.104";
|
|
28
28
|
|
|
29
29
|
let _distDir = dirname(fileURLToPath(import.meta.url));
|
|
30
30
|
if (_distDir.endsWith("chunks"))
|
|
@@ -5,6 +5,16 @@ const normalizeCall = async (seo, ctx) => {
|
|
|
5
5
|
return await seo(ctx);
|
|
6
6
|
return seo || {};
|
|
7
7
|
};
|
|
8
|
+
function replacePath(_path, url) {
|
|
9
|
+
if (typeof url === "string") {
|
|
10
|
+
_path = joinURL(_path.replace("/**", ""), url);
|
|
11
|
+
} else {
|
|
12
|
+
Object.entries(url).forEach(([key, value]) => {
|
|
13
|
+
_path = _path.replace(`:${key}`, value);
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return _path;
|
|
17
|
+
}
|
|
8
18
|
export default eventHandler(async (event) => {
|
|
9
19
|
const url = event.req.url?.split("?")[0];
|
|
10
20
|
const flow = event.context.flow;
|
|
@@ -15,13 +25,13 @@ export default eventHandler(async (event) => {
|
|
|
15
25
|
const scripts = { head: [], bodyStart: [], bodyEnd: [] };
|
|
16
26
|
const chunks = { head: [], body: [] };
|
|
17
27
|
const generate = {};
|
|
18
|
-
const { page, locale, params, view, name: pageName } = flow.router.byUrl.lookup(url) || {};
|
|
28
|
+
const { page, locale, params, view, name: pageName, path: pagePath } = flow.router.byUrl.lookup(url) || {};
|
|
19
29
|
if (!page)
|
|
20
30
|
return;
|
|
21
31
|
if (view.bundle)
|
|
22
32
|
await flow.callHook("page:chunks", view.bundle, chunks);
|
|
23
33
|
const templateContext = {};
|
|
24
|
-
const
|
|
34
|
+
const isDynamic = !!Object.keys(params || {});
|
|
25
35
|
const contextPage = {
|
|
26
36
|
chunks,
|
|
27
37
|
locale
|
|
@@ -43,9 +53,13 @@ export default eventHandler(async (event) => {
|
|
|
43
53
|
contextPage.page = pageObject;
|
|
44
54
|
templateContext.locale = locale;
|
|
45
55
|
templateContext.view = view;
|
|
46
|
-
if (
|
|
56
|
+
if (isDynamic && page.dynamic) {
|
|
47
57
|
const pages = await page.dynamic.method({ locale, utils });
|
|
48
|
-
const dynamicPage = pages.find((_page) =>
|
|
58
|
+
const dynamicPage = pages.find((_page) => {
|
|
59
|
+
const aUrl = replacePath(pagePath, _page.url);
|
|
60
|
+
const bUrl = replacePath(pagePath, params);
|
|
61
|
+
return aUrl === bUrl;
|
|
62
|
+
});
|
|
49
63
|
if (!dynamicPage)
|
|
50
64
|
return;
|
|
51
65
|
if (page.dynamic.assign)
|
|
@@ -30,7 +30,7 @@ export default defineFlowPlugin(async (flow) => {
|
|
|
30
30
|
});
|
|
31
31
|
const cache = {};
|
|
32
32
|
function replacePath(_path, url) {
|
|
33
|
-
if (url === "string") {
|
|
33
|
+
if (typeof url === "string") {
|
|
34
34
|
_path = joinURL(_path.replace("/**", ""), url);
|
|
35
35
|
} else {
|
|
36
36
|
Object.entries(url).forEach(([key, value]) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@monkeyplus/flow",
|
|
3
|
-
"version": "5.0.0-rc.
|
|
3
|
+
"version": "5.0.0-rc.104",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.mjs",
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"dist"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@monkeyplus/flow-cli": "5.0.0-rc.
|
|
29
|
-
"@monkeyplus/flow-kit": "5.0.0-rc.
|
|
30
|
-
"@monkeyplus/flow-schema": "5.0.0-rc.
|
|
28
|
+
"@monkeyplus/flow-cli": "5.0.0-rc.104",
|
|
29
|
+
"@monkeyplus/flow-kit": "5.0.0-rc.104",
|
|
30
|
+
"@monkeyplus/flow-schema": "5.0.0-rc.104",
|
|
31
31
|
"@rollup/plugin-replace": "^4.0.0",
|
|
32
32
|
"@vueuse/head": "^0.7.6",
|
|
33
33
|
"c12": "^0.2.8",
|