starting to implement multilanguage directories
arnaucode arnaucode@gmail.com
Sun, 12 Nov 2017 01:06:34 +0100
3 files changed,
14 insertions(+),
8 deletions(-)
M
main.go
→
main.go
@@ -6,7 +6,6 @@ "os"
) const rawFolderPath = "./webInput" -const newFolderPath = "./webOutput" const konstruiConfigFile = "konstruiConfig.json" func main() {@@ -14,15 +13,18 @@ c.Green("getting files from /webInput")
c.Green("getting conifg from file konstruiConfig.json") //READ CONFIG: konstruiConfig.json - readKonstruiConfig(rawFolderPath + "/" + konstruiConfigFile) + konstruiConfigs := readKonstruiConfig(rawFolderPath + "/" + konstruiConfigFile) c.Green("configuration:") - fmt.Println(konstruiConfig) + fmt.Println(konstruiConfigs) c.Green("templating") //create directory webOutput _ = os.Mkdir("webOutput", os.ModePerm) //DO TEMPLATING - startTemplating(rawFolderPath, newFolderPath) + for _, konstruiConfig := range konstruiConfigs { + _ = os.Mkdir(konstruiConfig.OutputDir, os.ModePerm) + startTemplating(rawFolderPath, konstruiConfig.OutputDir, konstruiConfig) + } c.Green("webpage finished, files at /webOutput") }
M
readKonstruiConfig.go
→
readKonstruiConfig.go
@@ -18,18 +18,22 @@ Title string `json:"title"`
Author string `json:"author"` Github string `json:"github"` Website string `json:"website"` + OutputDir string `json:"outputDir"` + LangPrefix string `json:"langPrefix"` Files []string `json:"files"` RepeatPages []RepeatPages CopyRaw []string `json:"copyRaw"` } -var konstruiConfig KonstruiConfig +func readKonstruiConfig(path string) []KonstruiConfig { + var konstruiConfigs []KonstruiConfig -func readKonstruiConfig(path string) { file, e := ioutil.ReadFile(path) if e != nil { fmt.Println("error:", e) } content := string(file) - json.Unmarshal([]byte(content), &konstruiConfig) + json.Unmarshal([]byte(content), &konstruiConfigs) + + return konstruiConfigs }
M
templating.go
→
templating.go
@@ -245,7 +245,7 @@ }
return param1content, param2content } -func startTemplating(folderPath string, newDir string) { +func startTemplating(folderPath string, newDir string, konstruiConfig KonstruiConfig) { //FILES //do templating for each file in konstruiConfig.Files //konstrui-template