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.

44 lines
1.1 KiB

7 years ago
7 years ago
7 years ago
4 years ago
7 years ago
7 years ago
7 years ago
7 years ago
4 years ago
7 years ago
7 years ago
7 years ago
7 years ago
  1. package main
  2. import (
  3. "encoding/json"
  4. "io/ioutil"
  5. )
  6. //Post is the struct for each post of the blog
  7. type Post struct {
  8. Thumb string `json:"thumb"`
  9. Md string `json:"md"`
  10. MetaImg string `json:"metaimg"`
  11. MetaDescr string `json:"metadescr"`
  12. }
  13. //Config gets the config.json file into struct
  14. type Config struct {
  15. Title string `json:"title"`
  16. MetaImg string `json:"metaimg"`
  17. MetaDescr string `json:"metadescr"`
  18. RelativePath string `json:"relativePath"`
  19. PostsDir string `json:"postsDir"`
  20. AbsoluteUrl string `json:"absoluteUrl"`
  21. IndexTemplate string `json:"indexTemplate"`
  22. PostThumbTemplate string `json:"postThumbTemplate"`
  23. Posts []Post `json:"posts"`
  24. CopyRaw []string `json:"copyRaw"`
  25. OutputDir string `json:"outputDir"`
  26. }
  27. var config Config
  28. func readConfig(path string) {
  29. file, err := ioutil.ReadFile(path)
  30. check(err)
  31. content := string(file)
  32. json.Unmarshal([]byte(content), &config)
  33. if config.PostsDir != "" {
  34. config.PostsDir += "/"
  35. }
  36. if config.OutputDir == "" {
  37. config.OutputDir = defaultOutputDir
  38. }
  39. }