You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
915 B
33 lines
915 B
package components
|
|
|
|
import "net/http"
|
|
|
|
templ TextInput(name string, placeholder string, method string, endpoint string, hxTrigger string) {
|
|
<input
|
|
type="text"
|
|
name={ name }
|
|
placeholder={ placeholder }
|
|
hx-target="#result"
|
|
if method == "get" {
|
|
hx-get={ endpoint }
|
|
}
|
|
if method == "post" {
|
|
hx-post={ endpoint }
|
|
}
|
|
hx-trigger={ hxTrigger }
|
|
class={ "input join-item input-bordered input-primary w-full max-w-xs px-4 py-3 my-8" }
|
|
/>
|
|
}
|
|
|
|
templ NewSiteForm(endpoint string) {
|
|
<div class="result" id="result">Please enter name of your new Hugo site below 👇</div>
|
|
@TextInput("name","Enter Name","post",endpoint,"keyup changed delay:100ms")
|
|
}
|
|
|
|
func NewSite(w http.ResponseWriter, r *http.Request) {
|
|
if r.FormValue("name") != "" {
|
|
w.Write([]byte("New site created: " + r.FormValue("name") + " ✅" ))
|
|
return
|
|
}
|
|
w.Write([]byte("Please enter name of your new Hugo site below 👇"))
|
|
}
|
|
|