feat: loader for new site
This commit is contained in:
parent
ce117468ab
commit
fcf497b1a1
6
app.go
6
app.go
@ -139,6 +139,12 @@ func hugoNewSite(w http.ResponseWriter, r *http.Request) {
|
||||
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.
|
||||
|
@ -15,7 +15,8 @@ templ Homepage(sites []string) {
|
||||
}
|
||||
|
||||
<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" />
|
||||
<p id="new-site-loader" class="htmx-indicator">Creating new site...</p>
|
||||
</form>
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ func Homepage(sites []string) templ.Component {
|
||||
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 {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
Reference in New Issue
Block a user