Browse Source

feat: loader for new site

main
decentral1se 8 months ago
parent
commit
fcf497b1a1
No known key found for this signature in database GPG Key ID: 3789458B3D0C410
  1. 6
      app.go
  2. 3
      components/templates.templ
  3. 2
      components/templates_templ.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.

3
components/templates.templ

@ -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>
}

2
components/templates_templ.go

@ -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
}