summaryrefslogtreecommitdiff
path: root/pages/create.go
diff options
context:
space:
mode:
authorewy <ewy0@protonmail.com>2026-04-09 21:29:25 +0200
committerewy <ewy0@protonmail.com>2026-04-09 21:29:25 +0200
commitc2ab8ee9409ac26a95e9a4c80c8ada51a22313f1 (patch)
tree94a070e764abad211335a0f99a78ac181233976a /pages/create.go
parent6e896ae0e108eef385b46c26e770dc191ae936ba (diff)
Diffstat (limited to 'pages/create.go')
-rw-r--r--pages/create.go25
1 files changed, 14 insertions, 11 deletions
diff --git a/pages/create.go b/pages/create.go
index 5469ee8..f16d2d8 100644
--- a/pages/create.go
+++ b/pages/create.go
@@ -2,10 +2,13 @@ package pages
import (
"delayed.link/storage"
+ "embed"
_ "embed"
"html/template"
+ "io/fs"
"net/http"
"net/url"
+ "path/filepath"
"strconv"
"strings"
"time"
@@ -83,17 +86,17 @@ func Create(w http.ResponseWriter, r *http.Request) {
}
}
-//go:embed create.gohtml
-var recContent string
-
-//go:embed style.gohtml
-var style string
-
-//go:embed header.gohtml
-var header string
+//go:embed html
+var pages embed.FS
func init() {
- template.Must(tmpl.Parse(style))
- template.Must(tmpl.Parse(header))
- template.Must(tmpl.New("create").Parse(recContent))
+ entries, _ := pages.ReadDir("html")
+ for _, entry := range entries {
+ name := entry.Name()
+ if !entry.IsDir() && strings.HasSuffix(name, ".gohtml") {
+ tmplName := strings.SplitN(name, ".", 2)[0]
+ content, _ := fs.ReadFile(pages, filepath.Join("html", name))
+ template.Must(tmpl.New(tmplName).Parse(string(content)))
+ }
+ }
}