pug-site-core 3.0.7 → 3.0.8

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/lib/generate.js CHANGED
@@ -11,6 +11,7 @@ import {
11
11
  pathSymbol,
12
12
  obfuscateJavaScript,
13
13
  addTemplateScopeIsolation,
14
+ getJsonData,
14
15
  } from "./utils.js";
15
16
  import _ from "lodash";
16
17
  import async from "async";
@@ -683,8 +684,14 @@ export async function buildStatic() {
683
684
  ) {
684
685
  throw new Error(`数据获取函数 ${obj.getDataFn} 不存在或不是函数`);
685
686
  }
686
-
687
- const data = await getData[obj.getDataFn](lang);
687
+ let getDataFn = getData[obj.getDataFn].bind({
688
+ getR2Data: async (jsonPath) => {
689
+ jsonPath = paths.join(lang, jsonPath);
690
+ let data = await getJsonData(jsonPath);
691
+ return data;
692
+ },
693
+ });
694
+ const data = await getDataFn(lang);
688
695
 
689
696
  // 处理路径和函数名
690
697
  obj.inputPugPath = obj.inputPugPath.replace(/^\//, "");
package/lib/utils.js CHANGED
@@ -383,7 +383,6 @@ export async function getJsonData(jsonDataPath) {
383
383
  return jsonData;
384
384
  }
385
385
 
386
-
387
386
  /**
388
387
  * 为HTML字符串中的template标签添加作用域隔离(优化版本)
389
388
  * @param {string} htmlString - HTML字符串
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pug-site-core",
3
- "version": "3.0.7",
3
+ "version": "3.0.8",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -52,7 +52,7 @@
52
52
  "ws": "^8.18.0"
53
53
  },
54
54
  "license": "ISC",
55
- "description": "增加错误堆栈信息的处理",
55
+ "description": "增加getR2Data方法",
56
56
  "files": [
57
57
  "lib/",
58
58
  "index.js"