pug-site-core 3.0.1 → 3.0.3

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.
Files changed (2) hide show
  1. package/lib/generate.js +19 -18
  2. package/package.json +2 -2
package/lib/generate.js CHANGED
@@ -309,7 +309,7 @@ export async function fetchDataToJsonFile(args) {
309
309
  await checkData(data, language, obj.getDataFn);
310
310
  let outPutPath = obj.outPutPath.split("/").join(pathSymbol);
311
311
  if (Array.isArray(data)) {
312
- let name = outPutPath.split(pathSymbol).pop().replace(/\..*$/, "");
312
+ let name = outPutPath.split(pathSymbol).pop().replace(/\.[^.]*$/, "");
313
313
  const regex = /^\[.+\]$/;
314
314
  if (regex.test(name)) {
315
315
  let property = name.slice(1, -1);
@@ -508,14 +508,14 @@ export async function buildStatic() {
508
508
  let htmlPath
509
509
  try {
510
510
  if (fileName) {
511
- htmlPath = paths.resolveRoot(
512
- distOutputPath,
513
- lang,
514
- outputPath.replace(
515
- outputPath.split("/").pop().replace(/\..*$/, ""),
516
- fileName.replace(/\..*$/, "")
517
- )
518
- );
511
+ htmlPath = paths.resolveRoot(
512
+ distOutputPath,
513
+ lang,
514
+ outputPath.replace(
515
+ outputPath.split("/").pop().replace(/\.[^.]*$/, ""),
516
+ fileName.replace(/\.[^.]*$/, "")
517
+ )
518
+ );
519
519
  } else {
520
520
  htmlPath = paths.resolveRoot(distOutputPath, lang, outputPath);
521
521
  }
@@ -550,13 +550,13 @@ export async function buildStatic() {
550
550
  */
551
551
  async function processArrayData(pagesPugToFn, data, obj, funName, pagePath, commonData, lang) {
552
552
  try {
553
- const name = obj.outPutHtmlPath.split("/").pop().replace(/\..*$/, "");
553
+ const name = obj.outPutHtmlPath.split("/").pop().replace(/\.[^.]*$/, "");
554
554
  const regex = /^\[.+\]$/;
555
555
 
556
556
  if (regex.test(name)) {
557
557
  const property = name.slice(1, -1);
558
558
 
559
- await async.eachLimit(data, 12, async (dataItem, index) => {
559
+ await async.eachLimit(data, 64, async (dataItem, index) => {
560
560
  try {
561
561
  const fileName = dataItem[property];
562
562
  if (!fileName) {
@@ -601,11 +601,11 @@ export async function buildStatic() {
601
601
  async function processCustomBuildHtml(pagesPugToFn, lang, getData, commonData, dealWithEndFunName) {
602
602
  if (!config.customBuildHtml?.length) return;
603
603
 
604
- for (const obj of config.customBuildHtml) {
604
+ await async.eachLimit(config.customBuildHtml, 3, async (obj) => {
605
605
  try {
606
606
  // 检查语言过滤
607
607
  if (obj.includeLang?.length > 0 && !obj.includeLang.includes(lang)) {
608
- continue;
608
+ return;
609
609
  }
610
610
 
611
611
  // 获取数据
@@ -632,7 +632,7 @@ export async function buildStatic() {
632
632
  } catch (error) {
633
633
  throw new Error(`处理自定义HTML构建失败 [lang: ${lang}, config: ${JSON.stringify(obj)}]: ${error.message}`);
634
634
  }
635
- }
635
+ });
636
636
  }
637
637
 
638
638
  /**
@@ -644,7 +644,7 @@ export async function buildStatic() {
644
644
  await fse.readdir(langDataPath, { recursive: true })
645
645
  ).filter((fileName) => fileName.endsWith(".json"));
646
646
 
647
- await async.eachLimit(pagesAllJsonFileName, 12, async (jsonFileName) => {
647
+ await async.eachLimit(pagesAllJsonFileName, 64, async (jsonFileName) => {
648
648
  try {
649
649
  const data = await fse.readJSON(paths.resolveRoot(langDataPath, jsonFileName));
650
650
  const pugTemplate = data._template;
@@ -673,9 +673,9 @@ export async function buildStatic() {
673
673
  const htmlPath = paths.resolveRoot(
674
674
  distOutputPath,
675
675
  lang,
676
- finalPugTemplate.replace(/\..*$/, ".html")
676
+ finalPugTemplate.replace(/\.[^.]*$/, ".html")
677
677
  );
678
-
678
+ console.log(htmlPath);
679
679
  await fse.outputFile(htmlPath, html);
680
680
  } catch (error) {
681
681
  throw new Error(`处理JSON文件失败 [file: ${jsonFileName}]: ${error.message}`);
@@ -719,7 +719,7 @@ export async function buildStatic() {
719
719
  const PagesPugToFn = await import(paths.pagesPugFn);
720
720
 
721
721
  // 处理每种语言
722
- await async.each(config.languageList, async (lang) => {
722
+ await async.eachSeries(config.languageList, async (lang) => {
723
723
  try {
724
724
  console.log("开始处理语言:", lang);
725
725
  const langDataPath = paths.resolveRoot(jsonDataPath, lang);
@@ -743,6 +743,7 @@ export async function buildStatic() {
743
743
  // 处理页面JSON文件
744
744
  await processPageJsonFiles(PagesPugToFn, lang, langDataPath, commonData, dealWithEndFunName);
745
745
 
746
+ console.log("处理语言:", lang, "完成");
746
747
  } catch (error) {
747
748
  throw new Error(`处理语言 ${lang} 失败: ${error.message}`);
748
749
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pug-site-core",
3
- "version": "3.0.1",
3
+ "version": "3.0.3",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -51,7 +51,7 @@
51
51
  "ws": "^8.18.0"
52
52
  },
53
53
  "license": "ISC",
54
- "description": "修复并优化静态html打包功能、并将默认下载数据线程12->3",
54
+ "description": "修复对带.符号的文件名处理",
55
55
  "files": [
56
56
  "lib/",
57
57
  "index.js"