summaryrefslogtreecommitdiff
path: root/themes/blowfish/genLangLinks.js
diff options
context:
space:
mode:
authorChristoph Cullmann <cullmann@kde.org>2024-04-28 17:33:09 +0200
committerChristoph Cullmann <cullmann@kde.org>2024-04-28 17:33:09 +0200
commite77051ccc4b47951bfa4fde2be436b1bb2fb113b (patch)
treef0b75ee3521da9c8cd39dac4359212348f70e4e8 /themes/blowfish/genLangLinks.js
parent4b355837824ac2422d371acef790f0f4249255c7 (diff)
use https://github.com/nunocoracao/blowfish.git
Diffstat (limited to 'themes/blowfish/genLangLinks.js')
-rw-r--r--themes/blowfish/genLangLinks.js66
1 files changed, 66 insertions, 0 deletions
diff --git a/themes/blowfish/genLangLinks.js b/themes/blowfish/genLangLinks.js
new file mode 100644
index 0000000..6b5925b
--- /dev/null
+++ b/themes/blowfish/genLangLinks.js
@@ -0,0 +1,66 @@
+const fs = require('fs');
+
+const configDir = "./exampleSite/config/_default";
+const contentDir = "./exampleSite/content";
+const defaultLang = "en";
+
+var targetLangs = []
+
+function readConfigs() {
+ const files = fs.readdirSync(configDir);
+ files.forEach(file => {
+ console.log(file)
+ if(file.indexOf("languages.") > -1) {
+ var lang = file.split(".")[1];
+ console.log(lang)
+ if(lang != defaultLang) {
+ targetLangs.push(lang);
+ }
+ }
+ });
+}
+
+async function processFile(filePath, file) {
+ if (filePath.indexOf("index.md") > -1) {
+
+ console.log("processing", filePath)
+
+ for(var i in targetLangs) {
+ const targetLang = targetLangs[i];
+ var targetFilePath = filePath.replace(".md", "." + targetLang + ".md");
+ //var targetFileName = file.replace(".md", "." + targetLang + ".md");
+
+ if(fs.existsSync(targetFilePath)) {
+ console.log("file already exists", targetFilePath);
+ }else{
+ console.log("creating file", targetFilePath);
+ //fs.symlinkSync(file, targetFilePath, 'junction');
+ fs.copyFileSync(filePath, targetFilePath);
+ }
+ }
+
+ } else
+ return
+}
+
+async function processFolder(folderPath) {
+ const files = fs.readdirSync(folderPath);
+
+ for (var i in files) {
+ const file = files[i];
+ const filePath = `${folderPath}/${file}`;
+ const isDir = fs.lstatSync(filePath).isDirectory();
+ if (isDir) {
+ await processFolder(filePath);
+ } else {
+ await processFile(filePath, file);
+ }
+ }
+}
+
+async function createLinks() {
+ processFolder(contentDir);
+}
+
+readConfigs();
+createLinks(); \ No newline at end of file