Skip to content
Permalink
Browse files

Fix formspree. Add possibility to send request through plain HTTP POST (

#203)

* Fix formspree. Add possibility to send request through plain HTTP POST or ajax with toggle.

* Fix formspree. Add possibility to send request through plain HTTP POST or ajax with toggle. Improve hugo templating in contact.html

* Fix formspree. Add possibility to send request through plain HTTP POST or ajax with toggle. Add toggle to exampleSite/config.toml

* Fix formspree. Add possibility to send request through plain HTTP POST or ajax with toggle. Remove useless function.

* Fix formspree. Add possibility to send request through plain HTTP POST or ajax with toggle. Use custom class only for ajax.

* Fix formspree. Add possibility to send request through plain HTTP POST or ajax with toggle. Return if form is null.
  • Loading branch information...
vittorio88 authored and ryanfox1985 committed Apr 9, 2019
1 parent 25e51a9 commit cd3401ad5d6d18539a04d8a4aa260ca9db4113ef
Showing with 8 additions and 5 deletions.
  1. +2 −1 README.md
  2. +1 −0 exampleSite/config.toml
  3. +1 −1 layouts/partials/contact.html
  4. +4 −3 static/js/front.js
@@ -140,11 +140,12 @@ You can optionally add the google maps widget defining latitude and longitude in

Since this Hugo sites are static, the contact form uses [Formspree](https://formspree.io/) as a proxy. The form makes a POST request to their servers to send the actual email. Visitors can send up to a 1000 emails each month for free.

To enable the form in the contact page, just type your Formspree email in the `config.toml` file.
To enable the form in the contact page, just type your Formspree email in the `config.toml` file, and specify whether to use ajax(paid) to send request or plain HTTP POST(free).

```yaml
[params]
email = "your@email.com"
contact_form_ajax = false
```

### Menu
@@ -90,6 +90,7 @@ paginate = 10
#
# Enable the contact form by entering your Formspree.io email
email = "your@email.com"
contact_form_ajax = false

about_us = "<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</p>"
copyright = "Copyright (c) 2015 - 2016, YourCompany; all rights reserved."
@@ -15,7 +15,7 @@ <h3>{{ i18n "contactForm" }}</h3>

<div id="contact-message"></div>

<form class="contact-form" method="post" action="https://formspree.io/{{ .Site.Params.email }}">
<form {{ with .Site.Params.contact_form_ajax }}class="contact-form-ajax"{{ else }}{{ end }} method="post" action="https://formspree.io/{{ .Site.Params.email }}">
<div class="row">
<div class="col-sm-6">
<div class="form-group">
@@ -19,12 +19,13 @@ $(function () {
animations()
counters()
demo()
contactForm()
contactFormAjax()
})

// Ajax contact
function contactForm () {
var form = $('.contact-form')
function contactFormAjax () {
var form = $('.contact-form-ajax')
if (typeof form === 'undefined') return false
form.submit(function () {
$this = $(this)
$.post($(this).attr('action'),

0 comments on commit cd3401a

Please sign in to comment.
You can’t perform that action at this time.