aboutsummaryrefslogtreecommitdiff
path: root/handle_index.go
diff options
context:
space:
mode:
Diffstat (limited to 'handle_index.go')
-rw-r--r--handle_index.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/handle_index.go b/handle_index.go
index b9a8a0c..5d54e6a 100644
--- a/handle_index.go
+++ b/handle_index.go
@@ -2,7 +2,27 @@ package main
import (
"net/http"
+ "os"
)
func handle_index(w http.ResponseWriter, r *http.Request) {
+ data := make(map[string]any)
+
+ entries, err := os.ReadDir(config.Git.Root)
+ if err != nil {
+ w.Write([]byte("Error listing categories: " + err.Error()))
+ return
+ }
+
+ categories := []string{}
+ for _, entry := range entries {
+ categories = append(categories, entry.Name())
+ }
+ data["categories"] = categories
+
+ err = templates.ExecuteTemplate(w, "index", data)
+ if err != nil {
+ w.Write([]byte("Error rendering template: " + err.Error()))
+ return
+ }
}