Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempting to add formspree_form_path site variable #11

Merged
merged 1 commit into from
Nov 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# This config file is meant for settings that affect your whole blog, values
# which you are expected to set up once and rarely edit after that.
# This file is *NOT* reloaded automatically when you use 'bundle exec jekyll serve'.
# This file is *NOT* reloaded automatically when you use 'bundle exec jekyll serve'.
# If you change this file, please restart the server process.

# Site settings
Expand All @@ -16,7 +16,7 @@ theme: jekyll-agency
url : "" # the base hostname & protocol for your site, e.g. http://example.com
baseurl: "" # the subpath of your site, e.g. /blog

title : Your Awesome Website
title : Your Awesome Website
email : your-email@example.com #this is also the email contact forms will go to
description: "Site description"
author : Your Name
Expand All @@ -30,4 +30,8 @@ analytics:
collections:
portfolio:

markdown: kramdown
markdown: kramdown

# Uncomment following line to use Formspree form ID based URL instead of email based URL
# Details: https://help.formspree.io/hc/en-us/articles/360017735154-How-to-prevent-spam
# formspree_form_path: "f/a_form_id"
4 changes: 2 additions & 2 deletions _includes/contact.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ <h3 class="section-subheading text-muted">{{ site.data.sitetext.contact.text | d
</div>
<div class="row">
<div class="col-lg-12">
<form id="contactForm" action="https://formspree.io/{{ site.email }}" novalidate="novalidate" method="POST">
<!--name="sentMessage"-->
<form id="contactForm" action="https://formspree.io/{% if site.formspree_form_path %}{{ site.formspree_form_path }}{% else %}{{ site.email }}{% endif %}" novalidate="novalidate" method="POST">
<!--name="sentMessage"-->
<div class="row">
<div class="col-md-6">
<div class="form-group">
Expand Down
10 changes: 5 additions & 5 deletions assets/js/contact_me.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ $(function() {
submitSuccess: function($form, event) {
event.preventDefault(); // prevent default submit behaviour
// get values from FORM
var url = "https://formspree.io/" + "{{ site.email }}";
var url = "https://formspree.io/" + "{% if site.formspree_form_path %}{{ site.formspree_form_path }}{% else %}{{ site.email }}{% endif %}";
var name = $("input#name").val();
var email = $("input#email").val();
var phone = $("input#phone").val();
Expand All @@ -25,15 +25,15 @@ $(function() {
$.ajax({
url: url,
type: "POST",
dataType: "json",
dataType: "json",
data: {
name: name,
phone: phone,
email: email,
message: message
},
cache: false,

success: function() {
// Success message
$('#success').html("<div class='alert alert-success'>");
Expand All @@ -46,7 +46,7 @@ $(function() {
//clear all fields
$('#contactForm').trigger("reset");
},

error: function() {
// Fail message
$('#success').html("<div class='alert alert-danger'>");
Expand All @@ -57,7 +57,7 @@ $(function() {
//clear all fields
$('#contactForm').trigger("reset");
},

complete: function() {
setTimeout(function() {
$this.prop("disabled", false); // Re-enable submit button when AJAX call is complete
Expand Down