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