You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
567 B
Go
33 lines
567 B
Go
6 years ago
|
package static
|
||
|
|
||
|
import (
|
||
|
"git.sp4ke.com/sp4ke/hugobot/v3/config"
|
||
|
"encoding/json"
|
||
|
"os"
|
||
|
"path/filepath"
|
||
|
)
|
||
|
|
||
|
var data = map[string]interface{}{
|
||
|
"bolts": map[string]interface{}{
|
||
|
"names": BoltNames,
|
||
|
},
|
||
|
}
|
||
|
|
||
|
// Json Export Static Data
|
||
|
func HugoExportData() error {
|
||
|
dirPath := filepath.Join(config.HugoData())
|
||
|
for k, v := range data {
|
||
|
filePath := filepath.Join(dirPath, k+".json")
|
||
|
outputFile, err := os.Create(filePath)
|
||
|
defer outputFile.Close()
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
jsonEnc := json.NewEncoder(outputFile)
|
||
|
jsonEnc.Encode(v)
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
}
|