@monkeyplus/flow 6.0.5 → 6.0.7
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/modules/content/module.mjs +17 -2
- package/modules/content/query.d.ts +25 -0
- package/modules/content/query.mjs +105 -19
- package/modules/content/runtime/client.d.ts +2 -0
- package/modules/content/runtime/client.mjs +1 -0
- package/modules/images/ipx.d.ts +5 -0
- package/modules/images/ipx.mjs +31 -0
- package/modules/images/module.d.ts +4 -0
- package/modules/images/module.mjs +96 -0
- package/modules/images/plugin.d.ts +2 -0
- package/modules/images/plugin.mjs +19 -0
- package/modules/images/runtime/build.d.ts +6 -0
- package/modules/images/runtime/build.mjs +142 -0
- package/modules/images/runtime/helpers.d.ts +16 -0
- package/modules/images/runtime/helpers.mjs +45 -0
- package/modules/images/runtime/image.d.ts +7 -0
- package/modules/images/runtime/image.mjs +235 -0
- package/modules/images/runtime/renames.d.ts +2 -0
- package/modules/images/runtime/renames.mjs +79 -0
- package/modules/images/runtime/server.d.ts +3 -0
- package/modules/images/runtime/server.mjs +68 -0
- package/modules/images/runtime/types.d.ts +77 -0
- package/modules/images/runtime/types.mjs +0 -0
- package/package.json +7 -1
- package/server/lib/pages.mjs +20 -21
- package/server/lib/render.mjs +28 -10
- package/server/renderer.d.ts +1 -1
- package/server/renderer.mjs +2 -1
- package/src/public/components.d.ts +3 -0
- package/src/public/components.mjs +3 -0
- package/src/public/index.d.ts +5 -3
- package/src/public/index.mjs +1 -0
- package/src/public/modules/images.d.ts +2 -0
- package/src/public/modules/images.mjs +1 -0
- package/src/public/query-content.d.ts +7 -0
- package/src/public/query-content.mjs +127 -0
- package/src/public/vite.mjs +18 -2
- package/src/runtime/components/MkImage.d.ts +188 -0
- package/src/runtime/components/MkImage.mjs +130 -0
- package/src/runtime/components/MkLink.d.ts +22 -0
- package/src/runtime/components/MkLink.mjs +72 -0
- package/src/runtime/components/MkPicture.d.ts +199 -0
- package/src/runtime/components/MkPicture.mjs +171 -0
- package/src/runtime/components/image-shared.d.ts +27 -0
- package/src/runtime/components/image-shared.mjs +51 -0
- package/src/runtime/config.d.ts +18 -0
- package/src/runtime/config.mjs +5 -2
- package/src/runtime/locale-routing.d.ts +12 -0
- package/src/runtime/locale-routing.mjs +93 -0
- package/src/runtime/page-discovery.mjs +8 -15
- package/src/runtime/pages.d.ts +16 -0
- package/src/runtime/virtual.d.ts +17 -0
- package/src/runtime/vue.mjs +6 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { existsSync, readdirSync } from "node:fs";
|
|
2
2
|
import { resolve } from "node:path";
|
|
3
3
|
import { createJiti } from "jiti";
|
|
4
|
+
import { localizeRoutePattern, normalizePath, toPublicRoute } from "./locale-routing.mjs";
|
|
4
5
|
const jiti = createJiti(import.meta.url, {
|
|
5
6
|
fsCache: false,
|
|
6
7
|
moduleCache: false
|
|
@@ -25,12 +26,6 @@ function collectFiles(rootDir, currentDir = rootDir) {
|
|
|
25
26
|
}
|
|
26
27
|
return files.sort((left, right) => left.localeCompare(right));
|
|
27
28
|
}
|
|
28
|
-
function normalizePath(value) {
|
|
29
|
-
if (!value || value === "/") {
|
|
30
|
-
return "/";
|
|
31
|
-
}
|
|
32
|
-
return value.length > 1 && value.endsWith("/") ? value.slice(0, -1) : value;
|
|
33
|
-
}
|
|
34
29
|
function createLocale(flowConfig, code) {
|
|
35
30
|
const [lang = flowConfig.locale.language || "es", loc = flowConfig.locale.location || "ec"] = code.split("-");
|
|
36
31
|
return {
|
|
@@ -55,9 +50,6 @@ function replacePath(pattern, url) {
|
|
|
55
50
|
}
|
|
56
51
|
return normalizePath(resolved.replaceAll("**", ""));
|
|
57
52
|
}
|
|
58
|
-
function toPublicRoutePattern(url) {
|
|
59
|
-
return normalizePath(url.replaceAll("*", ""));
|
|
60
|
-
}
|
|
61
53
|
function combineName(name, dynamicName) {
|
|
62
54
|
return `${name.replace(/\/*$/, "")}/${dynamicName.replace(/^\/*/, "")}`;
|
|
63
55
|
}
|
|
@@ -124,14 +116,15 @@ export async function getUrlFromDefinitions(definitions, flowConfig, namePage, l
|
|
|
124
116
|
return void 0;
|
|
125
117
|
}
|
|
126
118
|
const localePage = definition.locales[localeCode];
|
|
119
|
+
const localizedRoute = localizeRoutePattern(flowConfig, localeCode, localePage?.url || "/");
|
|
127
120
|
if (!localePage) {
|
|
128
121
|
return void 0;
|
|
129
122
|
}
|
|
130
123
|
if (options.url) {
|
|
131
|
-
return replacePath(
|
|
124
|
+
return replacePath(localizedRoute, options.url);
|
|
132
125
|
}
|
|
133
126
|
if (options.params) {
|
|
134
|
-
return replacePath(
|
|
127
|
+
return replacePath(localizedRoute, options.params);
|
|
135
128
|
}
|
|
136
129
|
if (localePage.dynamic && options.dynamicName) {
|
|
137
130
|
const entries = await getDynamicEntries(definitions, flowConfig, definition, localeCode, localePage);
|
|
@@ -139,9 +132,9 @@ export async function getUrlFromDefinitions(definitions, flowConfig, namePage, l
|
|
|
139
132
|
if (!entry) {
|
|
140
133
|
return void 0;
|
|
141
134
|
}
|
|
142
|
-
return replacePath(
|
|
135
|
+
return replacePath(localizedRoute, entry.url);
|
|
143
136
|
}
|
|
144
|
-
return
|
|
137
|
+
return toPublicRoute(flowConfig, localeCode, localePage.url);
|
|
145
138
|
}
|
|
146
139
|
export async function getUrlsFromDefinitions(definitions, flowConfig, withLocale = false, omitNoPublish = false) {
|
|
147
140
|
const urls = [];
|
|
@@ -157,12 +150,12 @@ export async function getUrlsFromDefinitions(definitions, flowConfig, withLocale
|
|
|
157
150
|
if (localePage.dynamic) {
|
|
158
151
|
const entries = await getDynamicEntries(definitions, flowConfig, definition, localeCode, localePage);
|
|
159
152
|
for (const entry of entries) {
|
|
160
|
-
const url2 = replacePath(localePage.url, entry.url);
|
|
153
|
+
const url2 = replacePath(localizeRoutePattern(flowConfig, localeCode, localePage.url), entry.url);
|
|
161
154
|
urls.push(withLocale ? { url: url2, locale: localeCode, name: combineName(definition.name, entry.name) } : url2);
|
|
162
155
|
}
|
|
163
156
|
continue;
|
|
164
157
|
}
|
|
165
|
-
const url =
|
|
158
|
+
const url = toPublicRoute(flowConfig, localeCode, localePage.url);
|
|
166
159
|
urls.push(withLocale ? { url, locale: localeCode, name: definition.name } : url);
|
|
167
160
|
}
|
|
168
161
|
}
|
package/src/runtime/pages.d.ts
CHANGED
|
@@ -66,6 +66,19 @@ export interface PageUrlInfo {
|
|
|
66
66
|
locale: string;
|
|
67
67
|
name: string;
|
|
68
68
|
}
|
|
69
|
+
export interface PageContextImageMeta {
|
|
70
|
+
rename?: string;
|
|
71
|
+
name: string;
|
|
72
|
+
alt?: string;
|
|
73
|
+
title?: string;
|
|
74
|
+
}
|
|
75
|
+
export type PageContextGetImage = ((input: string, modifiers?: Record<string, any>, options?: Record<string, unknown>) => unknown) & {
|
|
76
|
+
getSizes?: (input: string, options: any) => {
|
|
77
|
+
src?: string;
|
|
78
|
+
sizes: string;
|
|
79
|
+
srcset: string;
|
|
80
|
+
};
|
|
81
|
+
};
|
|
69
82
|
export interface PageViewDefinition {
|
|
70
83
|
bundle?: string;
|
|
71
84
|
template: string;
|
|
@@ -77,6 +90,9 @@ export interface PageContextUtils {
|
|
|
77
90
|
getLocale: () => FlowLocale;
|
|
78
91
|
getUrl: (namePage: string, localeCode?: string, options?: GetUrlOptions) => Promise<string | undefined>;
|
|
79
92
|
getUrls: (withLocale?: boolean, omitNoPublish?: boolean) => Promise<Array<string | PageUrlInfo>>;
|
|
93
|
+
getImage?: PageContextGetImage;
|
|
94
|
+
getImageMeta?: (src: string) => PageContextImageMeta | undefined;
|
|
95
|
+
getImageOptions?: () => Record<string, unknown>;
|
|
80
96
|
}
|
|
81
97
|
export interface PageContextInput {
|
|
82
98
|
locale: FlowLocale;
|
package/src/runtime/virtual.d.ts
CHANGED
|
@@ -38,6 +38,23 @@ declare module 'virtual:flow/strapi-config' {
|
|
|
38
38
|
export default config;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
declare module 'virtual:flow/content-config' {
|
|
42
|
+
const config: {
|
|
43
|
+
apiBase: string;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export default config;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
declare module '#flow-content-server' {
|
|
50
|
+
export {
|
|
51
|
+
buildContentTree,
|
|
52
|
+
findContentEntries,
|
|
53
|
+
findContentTree,
|
|
54
|
+
readContentEntries,
|
|
55
|
+
} from '../../modules/content/query.ts';
|
|
56
|
+
}
|
|
57
|
+
|
|
41
58
|
declare module '#strapi' {
|
|
42
59
|
export interface StrapiFetchOptions extends RequestInit {
|
|
43
60
|
params?: Record<string, unknown>;
|
package/src/runtime/vue.mjs
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import ui from "@nuxt/ui/vue-plugin";
|
|
2
|
+
import MkImage from "./components/MkImage.mjs";
|
|
3
|
+
import MkLink from "./components/MkLink.mjs";
|
|
4
|
+
import MkPicture from "./components/MkPicture.mjs";
|
|
2
5
|
export function installFlowVuePlugins(app, { ui: enableUi } = { ui: true }) {
|
|
3
6
|
if (enableUi) {
|
|
4
7
|
app.use(ui);
|
|
5
8
|
}
|
|
9
|
+
app.component("MkImage", MkImage);
|
|
10
|
+
app.component("MkLink", MkLink);
|
|
11
|
+
app.component("MkPicture", MkPicture);
|
|
6
12
|
return app;
|
|
7
13
|
}
|