diff --git a/main.go b/main.go index 50a8b17..7fe378e 100755 --- a/main.go +++ b/main.go @@ -6,7 +6,6 @@ import ( ) const rawFolderPath = "./webInput" -const newFolderPath = "./webOutput" const konstruiConfigFile = "konstruiConfig.json" func main() { @@ -14,15 +13,18 @@ func main() { 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") } diff --git a/readKonstruiConfig.go b/readKonstruiConfig.go index ece3dba..bfdc262 100755 --- a/readKonstruiConfig.go +++ b/readKonstruiConfig.go @@ -18,18 +18,22 @@ type KonstruiConfig struct { 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 } diff --git a/templating.go b/templating.go index 2bd7aaa..6899e3b 100644 --- a/templating.go +++ b/templating.go @@ -245,7 +245,7 @@ func getTagParameters(line string, tagname string, param1 string, param2 string) 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