aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorWilliam Hergès <william@herges.fr>2025-08-15 21:30:44 +0200
committerWilliam Hergès <william@herges.fr>2025-08-15 21:30:44 +0200
commit3b37150f6ee5d4aa40028f249891bbed73c96f1c (patch)
tree4152b4a58df33b74ab362731fee6fd9cabb72710 /main.go
parent91f2ef06c09b7dce9c5a9708f6d9d40ee157a90f (diff)
refactor(config): scope folder per config file
Diffstat (limited to 'main.go')
-rw-r--r--main.go23
1 files changed, 21 insertions, 2 deletions
diff --git a/main.go b/main.go
index 35f8e78..f8f82aa 100644
--- a/main.go
+++ b/main.go
@@ -75,6 +75,9 @@ func main() {
if err != nil {
panic(err)
}
+
+ cfg.folder = getFolder(configPath)
+
customPages, err := cfg.LoadCustomPages()
if err != nil {
panic(err)
@@ -84,13 +87,13 @@ func main() {
if dev {
g = golatt.New(
golatt.UsableEmbedFS("templates", templates),
- os.DirFS(getPath("public")),
+ os.DirFS(cfg.folder+"public"),
os.DirFS("dist"),
)
} else {
g = golatt.New(
golatt.UsableEmbedFS("templates", templates),
- os.DirFS(getPath("public")),
+ os.DirFS(cfg.folder+"public"),
golatt.UsableEmbedFS("dist", assets),
)
}
@@ -148,6 +151,22 @@ func main() {
}
}
+func getFolder(path string) string {
+ if !strings.Contains(path, "/") {
+ return ""
+ }
+ sp := strings.Split(path, "/")
+ folder := strings.Join(sp[1:len(sp)-1], "/")
+ if path[0] != '/' && !strings.HasPrefix(path, "./") {
+ if len(folder) == 0 {
+ folder = sp[0]
+ } else {
+ folder = sp[0] + "/" + folder
+ }
+ }
+ return folder + "/"
+}
+
func generateConfigFile(isToml bool) {
cfg := Config{
Image: "wallpaper.webp",