This is an automated email from the ASF dual-hosted git repository.

wangzx pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/echarts-doc.git


The following commit(s) were added to refs/heads/master by this push:
     new 21ad8fdf fix(build): replace the `${lang}` var in all config items 
when md2json. (see 
https://github.com/apache/echarts-doc/commit/df13f10d6efc48884d9c4c09998a2112d7249790#diff-8acc21ceac13631923ed1a6a0406ec62f5d8898ea1725bf8aaeb695ac1b825d9R1250)
21ad8fdf is described below

commit 21ad8fdf28e485e5b9b8d76f3c58c2e79b2bbc1f
Author: plainheart <[email protected]>
AuthorDate: Sun Sep 28 13:21:53 2025 +0800

    fix(build): replace the `${lang}` var in all config items when md2json. 
(see 
https://github.com/apache/echarts-doc/commit/df13f10d6efc48884d9c4c09998a2112d7249790#diff-8acc21ceac13631923ed1a6a0406ec62f5d8898ea1725bf8aaeb695ac1b825d9R1250)
---
 build/build-doc.js | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/build/build-doc.js b/build/build-doc.js
index ac0d8e70..a7d49f9c 100644
--- a/build/build-doc.js
+++ b/build/build-doc.js
@@ -23,7 +23,7 @@ const chalk = require('chalk');
 const argv = require('yargs').argv;
 const path = require('path');
 const chokidar = require('chokidar');
-const {debounce} = require('lodash');
+const {debounce, cloneDeep} = require('lodash');
 const {getDocJSONPVarNname} = require('../src/shared');
 const {readConfigEnvFile} = require('./helper');
 
@@ -63,17 +63,24 @@ for (let key in config) {
 }
 
 async function md2jsonAsync(opt) {
-
     var newOpt = Object.assign({
         path: path.join(opt.language, opt.entry, '**/*.md'),
-        tplEnv: Object.assign({}, config, {
-            galleryViewPath: config.galleryViewPath.replace('${lang}', 
opt.language),
-            galleryEditorPath: config.galleryEditorPath.replace('${lang}', 
opt.language),
-            handbookPath: config.handbookPath.replace('${lang}', opt.language)
-        }),
+        tplEnv: replaceLangInConfig(cloneDeep(config)),
         imageRoot: config.imagePath
     }, opt);
 
+    function replaceLangInConfig(config) {
+        for (const [prop, value] of Object.entries(config)) {
+            if (typeof value === 'object' && value) {
+                replaceLangInConfig(value)
+            }
+            else if (typeof value === 'string') {
+                config[prop] = value.replace('${lang}', opt.language)
+            }
+        }
+        return config;
+    }
+
     function run(cb) {
         md2json(newOpt).then(schema => {
             writeSingleSchema(schema, opt.language, opt.entry, false);


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to