You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by ur...@apache.org on 2022/09/22 06:22:47 UTC

[pulsar-site] 01/01: fix build error due to i18n docs error

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

urfree pushed a commit to branch fix-i18n-docs
in repository https://gitbox.apache.org/repos/asf/pulsar-site.git

commit 986a63c70d8e47a36c80394dc9593e42de0f93b5
Author: Li Li <ur...@apache.org>
AuthorDate: Thu Sep 22 14:22:34 2022 +0800

    fix build error due to i18n docs error
    
    Signed-off-by: Li Li <ur...@apache.org>
---
 site2/website-next/scripts/fix-i18n.js            | 32 +++++++++++++++++++++++
 site2/website-next/scripts/split-version-build.sh |  2 ++
 2 files changed, 34 insertions(+)

diff --git a/site2/website-next/scripts/fix-i18n.js b/site2/website-next/scripts/fix-i18n.js
new file mode 100644
index 00000000000..39e0824534a
--- /dev/null
+++ b/site2/website-next/scripts/fix-i18n.js
@@ -0,0 +1,32 @@
+const fs = require("fs");
+const path = require("path");
+
+function travel(dir, callback) {
+  fs.readdirSync(dir).forEach((file) => {
+    var pathname = path.join(dir, file);
+    if (fs.statSync(pathname).isDirectory()) {
+      travel(pathname, callback);
+    } else {
+      callback(pathname);
+    }
+  });
+}
+
+function fixMd(mdpath) {
+  let data = fs.readFileSync(mdpath, "utf8");
+  data = data.replace(/href=“([^”]+)”/, '"href="$1"');
+  fs.writeFileSync(mdpath, data);
+  console.log(mdpath + " i18n fixed");
+}
+
+module.exports = (dir) => {
+  travel(dir, fixMd);
+};
+
+//Test
+if (typeof require !== "undefined" && require.main === module) {
+  travel(
+    path.join(__dirname, "../i18n/zh-CN/docusaurus-plugin-content-docs"),
+    fixMd
+  );
+}
diff --git a/site2/website-next/scripts/split-version-build.sh b/site2/website-next/scripts/split-version-build.sh
index 2dc679ddf26..b4181beb32c 100755
--- a/site2/website-next/scripts/split-version-build.sh
+++ b/site2/website-next/scripts/split-version-build.sh
@@ -93,6 +93,8 @@ fi
 
 cp scripts/code.json i18n/en/
 
+node scripts/fix-i18n.js
+
 # Build only the versions that has changed
 # Build next version that has any changed
 while read version; do