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.

45 lines
1.2 KiB

6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
4 years ago
6 years ago
6 years ago
6 years ago
6 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. OutsideArticle string `json:"outsideArticle"`
  13. }
  14. // Config gets the config.json file into struct
  15. type Config struct {
  16. Title string `json:"title"`
  17. MetaImg string `json:"metaimg"`
  18. MetaDescr string `json:"metadescr"`
  19. RelativePath string `json:"relativePath"`
  20. PostsDir string `json:"postsDir"`
  21. AbsoluteUrl string `json:"absoluteUrl"`
  22. IndexTemplate string `json:"indexTemplate"`
  23. PostThumbTemplate string `json:"postThumbTemplate"`
  24. Posts []Post `json:"posts"`
  25. CopyRaw []string `json:"copyRaw"`
  26. OutputDir string `json:"outputDir"`
  27. }
  28. var config Config
  29. func readConfig(path string) {
  30. file, err := ioutil.ReadFile(path)
  31. check(err)
  32. content := string(file)
  33. json.Unmarshal([]byte(content), &config)
  34. if config.PostsDir != "" {
  35. config.PostsDir += "/"
  36. }
  37. if config.OutputDir == "" {
  38. config.OutputDir = defaultOutputDir
  39. }
  40. }