pretty run

This commit is contained in:
Nuno Coração
2025-06-17 23:17:26 +01:00
parent 560e927b87
commit f2e224a042
137 changed files with 5771 additions and 5017 deletions

View File

@@ -1,66 +1,63 @@
const fs = require('fs');
const fs = require("fs");
const configDir = "./exampleSite/config/_default";
const contentDir = "./exampleSite/content";
const defaultLang = "en";
var targetLangs = []
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);
}
}
});
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) {
if (filePath.indexOf("index.md") > -1) {
console.log("processing", filePath);
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");
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
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);
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);
}
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);
processFolder(contentDir);
}
readConfigs();
createLinks();
createLinks();