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:23:45 UTC

[pulsar-site] branch main updated: fix build error due to i18n docs error (#220)

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

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


The following commit(s) were added to refs/heads/main by this push:
     new 3f09c14f93e fix build error due to i18n docs error (#220)
3f09c14f93e is described below

commit 3f09c14f93e98f76ae4b6d57f83585684fe440e4
Author: Li Li <ur...@apache.org>
AuthorDate: Thu Sep 22 14:23:40 2022 +0800

    fix build error due to i18n docs error (#220)
---
 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