feat: loader for new site

This commit is contained in:
decentral1se 2024-04-11 15:39:53 +02:00
parent ce117468ab
commit fcf497b1a1
No known key found for this signature in database
GPG Key ID: 03789458B3D0C410
3 changed files with 9 additions and 2 deletions

6
app.go
View File

@ -139,6 +139,12 @@ func hugoNewSite(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(fmt.Sprintf("unable to clone 'nostyleplease' theme: %s", err))) w.Write([]byte(fmt.Sprintf("unable to clone 'nostyleplease' theme: %s", err)))
} }
sites, err := existingSites()
if err != nil {
w.Write([]byte(fmt.Sprintf("unable to list existing sites: %s", err)))
}
templ.Handler(components.Homepage(sites)).ServeHTTP(w, r)
} }
// NewRouter creates a new web router. // NewRouter creates a new web router.

View File

@ -15,7 +15,8 @@ templ Homepage(sites []string) {
} }
<div>Create a new Hugo site below 👇</div> <div>Create a new Hugo site below 👇</div>
<form id="new-site-form" hx-post="/hugo/new" hx-trigger="submit"> <form id="new-site-form" hx-post="/hugo/new" hx-indicator="#new-site-loader" hx-trigger="submit">
<input type="text" required="required" name="site-name" /> <input type="text" required="required" name="site-name" />
<p id="new-site-loader" class="htmx-indicator">Creating new site...</p>
</form> </form>
} }

View File

@ -65,7 +65,7 @@ func Homepage(sites []string) templ.Component {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
} }
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div>Create a new Hugo site below 👇</div><form id=\"new-site-form\" hx-post=\"/hugo/new\" hx-trigger=\"submit\"><input type=\"text\" required=\"required\" name=\"site-name\"></form>") _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div>Create a new Hugo site below 👇</div><form id=\"new-site-form\" hx-post=\"/hugo/new\" hx-indicator=\"#new-site-loader\" hx-trigger=\"submit\"><input type=\"text\" required=\"required\" name=\"site-name\"><p id=\"new-site-loader\" class=\"htmx-indicator\">Creating new site...</p></form>")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }