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

Adds i18n support to the theme #49

Merged
merged 11 commits into from
Jun 2, 2019
Next Next commit
Added Basin as alternative AJAX contact form option
  • Loading branch information
tomanistor committed Apr 15, 2018
commit caa10a822280b6c2d931b57d53ee6b9bf5495154
6 changes: 2 additions & 4 deletions layouts/partials/body-bottom.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
{{ if .IsHome }}
<script src="/scripts/{{ if .Site.Params.cacheBustJS }}{{ index .Site.Data.cachedAssets "index.js" }}{{ else }}index.min.js{{ end }}" type="text/javascript"></script>
{{ if .Site.Params.ajaxFormspree }}
<script>
{{ partial "scripts/contact.min.js" . | safeJS }}
</script>
{{ if or (.Site.Params.ajaxFormspree) (.Site.Params.ajaxBasin) }}
<script>{{ partial "scripts/contact.min.js" . | safeJS }}</script>
{{ end }}
{{ else }}
<script src="/scripts/{{ if .Site.Params.cacheBustJS }}{{ index .Site.Data.cachedAssets "main.js" }}{{ else }}main.min.js{{ end }}" type="text/javascript"></script>
Expand Down
6 changes: 4 additions & 2 deletions layouts/partials/contact.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{ if .Site.Params.ajaxFormspree }}
{{ if or (.Site.Params.ajaxFormspree) (.Site.Params.ajaxBasin) }}
<section class="contact" id="contact">
<div class="container">

Expand All @@ -8,14 +8,16 @@ <h1>Let's Chat</h1>
</div>
</div>

<form id="form-contact" action="https://formspree.io/{{ .Site.Params.email }}" method="POST">
<form id="form-contact" action="{{ if .Site.Params.ajaxFormspree }}https://formspree.io/{{ .Site.Params.email }}{{ else if .Site.Params.ajaxBasin }}{{ .Site.Params.ajaxBasin }}{{ end }}" method="POST">
<div class="row center-xs">
<div class="col-xs-12 col-sm-6"><input type="text" name="name" placeholder="Name" required></div>
<div class="col-xs-12 col-sm-6"><input type="email" name="email" placeholder="Email" required></div>
<div class="col-xs-12"><input type="text" name="_subject" placeholder="Subject" required></div>
<div class="col-xs-12"><textarea name="message" placeholder="Message" required></textarea></div>
{{ if .Site.Params.ajaxFormspree }}
<input type="text" name="_gotcha" style="display:none">
<input type="hidden" name="_next" value="/">
{{ end }}
<div class="col-xs-12 contact-submit">
<input id="form-submit" type="submit" value="Send">
<span id="form-thankyou" style="visibility:hidden">Thanks for your email!</span>
Expand Down
8 changes: 4 additions & 4 deletions layouts/partials/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@

<title>
{{ $url := replace .Permalink ( printf "%s" .Site.BaseURL) "" }}
{{ if .IsHome }}
{{- if .IsHome -}}
{{ .Site.Title }}
{{ else if .Params.heading }}
{{- else if .Params.heading -}}
{{ .Params.heading }}
{{ else }}
{{- else -}}
{{ .Title }} | {{ .Site.Title }}
{{ end }}
{{- end -}}
</title>

<meta name="title" content="{{ if .IsHome }}{{ .Site.Title }}{{ else if .Params.heading }}{{ .Params.heading }}{{ else }}{{ .Title }} | {{ .Site.Title }}{{ end}}">
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/scripts/contact.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion static/scripts/contact.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions static/scripts/src/contact.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ $('#form-contact').addEventListener('submit', function(e) {
message:message,
}

// Send to Formspree
request.open('POST', 'https://formspree.io/{{ .Site.Params.email }}', true);
request.setRequestHeader('Content-Type', 'application/json; charset=UTF-8');
// Send to Formspree or Basin
request.open('POST', '{{ if .Site.Params.ajaxFormspree }}https://formspree.io/{{ .Site.Params.email }}{{ else if .Site.Params.ajaxBasin }}{{ .Site.Params.ajaxBasin }}.json{{ end }}', true);
request.setRequestHeader('Accept', 'application/json; charset=UTF-8');
// Call function when the state changes
request.onreadystatechange = function() {
if (request.readyState == 4 && request.status == 200) {
Expand Down