@monkeyplus/flow 6.0.38 → 6.0.40

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.
@@ -42,8 +42,23 @@ function parseContentFile(keyPath, raw) {
42
42
  const extension = extname(keyPath).toLowerCase();
43
43
  const normalizedPath = normalizeContentPath(keyPath);
44
44
  if (extension === ".json") {
45
- const parsed = typeof raw === "string" ? JSON.parse(raw) : raw;
46
- const body = typeof raw === "string" ? raw : JSON.stringify(raw);
45
+ let parsed = {};
46
+ let body = raw;
47
+ if (typeof raw === "string") {
48
+ body = raw;
49
+ const trimmed = raw.trim();
50
+ if (trimmed) {
51
+ try {
52
+ parsed = JSON.parse(trimmed);
53
+ } catch (e) {
54
+ consola.warn("parseContentFile", keyPath, e);
55
+ parsed = {};
56
+ }
57
+ }
58
+ } else {
59
+ parsed = raw;
60
+ body = JSON.stringify(raw);
61
+ }
47
62
  return {
48
63
  ...normalizedPath,
49
64
  extension,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monkeyplus/flow",
3
- "version": "6.0.38",
3
+ "version": "6.0.40",
4
4
  "description": "@monkeyplus/flow package-first runtime with Vite, Nitro, Vue and a workspace playground.",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -27,6 +27,7 @@ export function createFlowNitroConfig(options = {}) {
27
27
  const moduleRuntimeConfig = { ...flowModules.nitro.runtimeConfig };
28
28
  delete moduleRuntimeConfig.flow;
29
29
  return defineNitroConfig({
30
+ ...flowNitroConfig,
30
31
  compatibilityDate: "2026-04-02",
31
32
  builder: "vite",
32
33
  renderer: {
@@ -72,7 +73,16 @@ export function createFlowNitroConfig(options = {}) {
72
73
  ...flowModules.nitro.routeRules
73
74
  },
74
75
  routes: flowModules.nitro.routes,
75
- imports: flowModules.nitro.imports,
76
+ imports: {
77
+ ...flowModules.nitro.imports,
78
+ imports: [
79
+ ...flowModules.nitro.imports?.imports || [],
80
+ { name: "definePage", from: "@monkeyplus/flow" },
81
+ { name: "queryContent", from: "@monkeyplus/flow" },
82
+ { name: "useSchemaOrg", from: "@monkeyplus/flow" },
83
+ { name: "defineLayoutContext", from: "@monkeyplus/flow" }
84
+ ]
85
+ },
76
86
  runtimeConfig: {
77
87
  app: {
78
88
  name: "Flow Next",
@@ -7,6 +7,7 @@ export interface QueryContentBuilder {
7
7
  select: (...fields: string[]) => QueryContentBuilder;
8
8
  find: () => Promise<ContentEntry[]>;
9
9
  findOne: () => Promise<ContentEntry | null>;
10
+ findEntries: () => Promise<Record<string, unknown>>;
10
11
  all: () => Promise<ContentEntry[]>;
11
12
  first: () => Promise<ContentEntry | null>;
12
13
  surround: (targetPath: string) => Promise<[ContentEntry | null, ContentEntry | null]>;
@@ -176,6 +176,15 @@ export function queryContent(path = "") {
176
176
  const entries = await this.find();
177
177
  return entries[0] || null;
178
178
  },
179
+ async findEntries() {
180
+ const entries = await this.find();
181
+ return entries.reduce((acc, curr) => {
182
+ return {
183
+ ...acc,
184
+ [curr.name]: curr.data
185
+ };
186
+ }, {});
187
+ },
179
188
  async all() {
180
189
  return await this.find();
181
190
  },
@@ -1,5 +1,2 @@
1
1
  export default function(nitroApp) {
2
- if (!globalThis.$fetch && nitroApp) {
3
- globalThis.$fetch = nitroApp.fetch;
4
- }
5
2
  }
@@ -14,9 +14,6 @@ export function createFlowBuildHooks(options) {
14
14
  const hooks = {
15
15
  ...options.existingHooks || {}
16
16
  };
17
- if (options.flowConfig.build.preset !== "ssg") {
18
- return hooks;
19
- }
20
17
  const userPrerenderRoutes = typeof hooks["prerender:routes"] === "function" ? hooks["prerender:routes"] : void 0;
21
18
  const userPrerenderGenerate = typeof hooks["prerender:generate"] === "function" ? hooks["prerender:generate"] : void 0;
22
19
  let prerenderRoutesPromise;