Added templ, tailwind and frankenui

This commit is contained in:
2025-02-05 01:51:06 +11:00
parent 5c8d4c5158
commit b6feed7c0c
18 changed files with 1754 additions and 21 deletions

View File

@@ -1,8 +1,8 @@
package handlers
import (
"html/template"
"net/http"
"projectreshoot/view/page"
)
func HandleRoot() http.Handler {
@@ -12,8 +12,7 @@ func HandleRoot() http.Handler {
http.NotFound(w, r)
return
}
templ := template.Must(template.ParseFiles("templates/index.html"))
templ.Execute(w, nil)
page.Index().Render(r.Context(), w)
},
)
}

36
handlers/static.go Normal file
View File

@@ -0,0 +1,36 @@
package handlers
import (
"net/http"
"os"
)
type justFilesFilesystem struct {
fs http.FileSystem
}
type neuteredReaddirFile struct {
http.File
}
func (fs justFilesFilesystem) Open(name string) (http.File, error) {
f, err := fs.fs.Open(name)
if err != nil {
return nil, err
}
return neuteredReaddirFile{f}, nil
}
func (f neuteredReaddirFile) Readdir(count int) ([]os.FileInfo, error) {
return nil, nil
}
func HandleStatic() http.Handler {
return http.HandlerFunc(
func(w http.ResponseWriter, r *http.Request) {
nfs := justFilesFilesystem{http.Dir("static")}
fs := http.FileServer(nfs)
fs.ServeHTTP(w, r)
},
)
}