aboutsummaryrefslogtreecommitdiff
path: root/data.go
diff options
context:
space:
mode:
authorAnhgelus Morhtuuzh <anhgelus@anhgelus.world>2025-03-03 11:20:29 +0100
committerAnhgelus Morhtuuzh <anhgelus@anhgelus.world>2025-03-03 11:20:29 +0100
commitaa5a93e978cf986bf39c3d0055e22efe0a1b50b0 (patch)
tree1ea84a8cb22d9ede86edec375e610a8aad0dd539 /data.go
parent383b67669aaddbc2f9f98b4f28718b515a2d2670 (diff)
feat(config): supports toml for custom pages
Diffstat (limited to 'data.go')
-rw-r--r--data.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/data.go b/data.go
index df85090..140f914 100644
--- a/data.go
+++ b/data.go
@@ -2,7 +2,9 @@ package main
import (
"encoding/json"
+ "errors"
"fmt"
+ "github.com/BurntSushi/toml"
"github.com/anhgelus/golatt"
"html/template"
"log/slog"
@@ -125,7 +127,13 @@ func (c *Config) LoadCustomPages() ([]*CustomPage, error) {
return nil, err
}
var p CustomPage
- err = json.Unmarshal(b, &p)
+ if strings.HasSuffix(cp, ".json") {
+ err = json.Unmarshal(b, &p)
+ } else if strings.HasSuffix(cp, ".toml") {
+ err = toml.Unmarshal(b, &p)
+ } else {
+ return nil, errors.New("custom page file must be .json or .toml")
+ }
if err != nil {
return nil, err
}