You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
975 B

  1. package main
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "io/ioutil"
  6. )
  7. //RepeatPages is from the json config, is an array inside KonstruiConfig
  8. type RepeatPages struct {
  9. HtmlPage string `json:"htmlPage"`
  10. Data string `json:"data"`
  11. }
  12. //KonstruiConfig is the configuration from the file konstruiConfig.json, on the folder /webInput
  13. type KonstruiConfig struct {
  14. Title string `json:"title"`
  15. Author string `json:"author"`
  16. Github string `json:"github"`
  17. Website string `json:"website"`
  18. OutputDir string `json:"outputDir"`
  19. LangPrefix string `json:"langPrefix"`
  20. Files []string `json:"files"`
  21. RepeatPages []RepeatPages
  22. CopyRaw []string `json:"copyRaw"`
  23. }
  24. func readKonstruiConfig(path string) []KonstruiConfig {
  25. var konstruiConfigs []KonstruiConfig
  26. file, e := ioutil.ReadFile(path)
  27. if e != nil {
  28. fmt.Println("error:", e)
  29. }
  30. content := string(file)
  31. json.Unmarshal([]byte(content), &konstruiConfigs)
  32. return konstruiConfigs
  33. }