contact.html 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. {{ $ := .root }}
  2. {{ $st := .page }}
  3. {{ $autolink := default true $st.Params.content.autolink }}
  4. {{ $data := site.Params }}
  5. {{ $form_provider := lower $st.Params.content.form.provider | default "" }}
  6. {{ $form_provider_legacy := $st.Params.email_form | default 0 }}
  7. {{ $use_netlify_form := eq $form_provider "netlify" | or (eq $form_provider_legacy 1) }}
  8. {{ $use_formspree_form := eq $form_provider "formspree" | or (eq $form_provider_legacy 2) }}
  9. {{ $use_form := or $use_netlify_form $use_formspree_form }}
  10. {{ $use_netlify_captcha := $st.Params.content.form.netlify.captcha | default true }}
  11. {{ $use_formspree_captcha := $st.Params.content.form.formspree.captcha | default false }}
  12. {{ $columns := $st.Params.design.columns | default "2" }}
  13. {{ if and $use_formspree_form $use_formspree_captcha }}
  14. <script src="https://www.google.com/recaptcha/api.js" async defer></script>
  15. {{ end }}
  16. <div class="col-12 {{if eq $columns "2"}}col-lg-8{{end}}">
  17. {{ with $st.Content }}{{ . }}{{ end }}
  18. {{ if $use_form }}
  19. {{ $post_action := "" }}
  20. {{ if $use_netlify_form }}
  21. {{ $post_action = "netlify" }}
  22. {{ else if $use_formspree_form }}
  23. {{ if not $st.Params.content.form.formspree.id }}
  24. {{ errorf "You have chosen to use Formspree as the provider for the contact form. Please set your Formspree Form ID in the Contact widget or disable the form.\nDocumentation: https://wowchemy.com/docs/widget/contact/" }}
  25. {{ end }}
  26. {{ if and $use_formspree_captcha (not $st.Params.content.form.formspree.captcha_key) }}
  27. {{ errorf "You have chosen to use reCAPTCHA for Formspree. Please set your Formspree CAPTCHA KEY in the Contact widget or disable reCAPTCHA.\nDocumentation: https://help.formspree.io/hc/en-us/articles/360022811154" }}
  28. {{ end }}
  29. {{ $post_action = printf "action=\"https://formspree.io/f/%s\"" $st.Params.content.form.formspree.id }}
  30. {{ end }}
  31. <div class="mb-3">
  32. <form name="contact" method="POST" {{ $post_action | safeHTMLAttr }} {{ if $use_netlify_form }}netlify-honeypot="_gotcha"{{ end }} {{ if $use_netlify_captcha }}data-netlify-recaptcha="true"{{ end }} {{ with $st.Params.content.form.netlify.success_url }}action="{{ . | relLangURL }}"{{ end }}>
  33. <div class="form-group form-inline">
  34. <label class="sr-only" for="inputName">{{ i18n "contact_name" }}</label>
  35. <input type="text" name="name" class="form-control w-100" id="inputName" placeholder="{{ i18n "contact_name" | default "Name" }}" required>
  36. </div>
  37. <div class="form-group form-inline">
  38. <label class="sr-only" for="inputEmail">{{ i18n "contact_email" }}</label>
  39. <input type="email" name="email" class="form-control w-100" id="inputEmail" placeholder="{{ i18n "contact_email" | default "Email" }}" required>
  40. </div>
  41. <div class="form-group">
  42. <label class="sr-only" for="inputMessage">{{ i18n "contact_message" }}</label>
  43. <textarea name="message" class="form-control" id="inputMessage" rows="5" placeholder="{{ i18n "contact_message" | default "Message" }}" required></textarea>
  44. </div>
  45. {{ if $st.Params.content.form.netlify.attachments }}
  46. <div class="form-group form-inline">
  47. <label class="sr-only" for="fileUpload">{{ i18n "contact_attachment" }}</label>
  48. <input type="file" name="file" class="form-control w-100" id="fileUpload" placeholder="{{ i18n "contact_attachment" | default "Attach file" }}">
  49. </div>
  50. {{ end }}
  51. <div class="d-none">
  52. <label>Do not fill this field unless you are a bot: <input name="_gotcha"></label>
  53. </div>
  54. {{ if and $use_netlify_form $use_netlify_captcha }}
  55. <div class="form-group" data-netlify-recaptcha="true"></div>
  56. {{ else if and $use_formspree_form $use_formspree_captcha }}
  57. <div class="g-recaptcha" data-sitekey="{{ $st.Params.content.form.formspree.captcha_key }}"></div>
  58. </br>
  59. {{ end }}
  60. <button type="submit" class="btn btn-primary px-3 py-2 w-100">{{ i18n "contact_send" | default "Send" }}</button>
  61. </form>
  62. </div>
  63. {{ end }}
  64. <ul class="fa-ul">
  65. {{ if $data.email }}
  66. <li>
  67. <i class="fa-li fas fa-envelope fa-2x" aria-hidden="true"></i>
  68. <span id="person-email">
  69. {{- if $autolink }}<a href="mailto:{{ $data.email }}">{{ $data.email }}</a>{{ else }}{{ $data.email }}{{ end -}}
  70. </span>
  71. </li>
  72. {{ end }}
  73. {{ with $data.phone }}
  74. <li>
  75. <i class="fa-li fas fa-phone fa-2x" aria-hidden="true"></i>
  76. <span id="person-telephone">
  77. {{- if $autolink }}<a href="tel:{{ . }}">{{ . }}</a>{{ else }}{{ . }}{{ end -}}
  78. </span>
  79. </li>
  80. {{ end }}
  81. {{ $addr_formatted := "" }}{{/* Scoping for maps. */}}
  82. {{ if $data.address.street | or $data.address.city | or $data.address.region | or $data.address.postcode | or $data.address.country }}
  83. {{ $addr_formatted = partial "functions/get_address" (dict "root" . "address" $data.address) }}
  84. <li>
  85. <i class="fa-li fas fa-map-marker fa-2x" aria-hidden="true"></i>
  86. <span id="person-address">{{$addr_formatted}}</span>
  87. </li>
  88. {{ end }}
  89. {{ with $data.directions }}
  90. <li>
  91. <i class="fa-li fas fa-compass fa-2x" aria-hidden="true"></i>
  92. <span>{{ . | markdownify | emojify }}</span>
  93. </li>
  94. {{ end }}
  95. {{ with $data.office_hours }}
  96. <li>
  97. <i class="fa-li fas fa-clock fa-2x" aria-hidden="true"></i>
  98. <span>
  99. {{- if not (reflect.IsSlice .)}}{{/* Support legacy string format. */}}
  100. {{- . | markdownify | emojify -}}
  101. {{else}}
  102. {{- delimit . "<br>" | markdownify | emojify -}}
  103. {{end -}}
  104. </span>
  105. </li>
  106. {{ end }}
  107. {{ with $data.appointment_url }}
  108. <li>
  109. <i class="fa-li fas fa-calendar-check fa-2x" aria-hidden="true"></i>
  110. <a href="{{ . }}" target="_blank" rel="noopener">{{ i18n "book_appointment" | default "Book an appointment" }}</a>
  111. </li>
  112. {{ end }}
  113. {{/* Contact links. */}}
  114. {{ range $data.contact_links }}
  115. {{ $pack := or .icon_pack "fas" }}
  116. {{ $pack_prefix := $pack }}
  117. {{ if in (slice "fab" "fas" "far" "fal") $pack }}
  118. {{ $pack_prefix = "fa" }}
  119. {{ end }}
  120. {{ $link := .link }}
  121. {{ $scheme := (urls.Parse $link).Scheme }}
  122. {{ $target := "" }}
  123. {{ if not $scheme }}
  124. {{ $link = .link | relLangURL }}
  125. {{ else if in (slice "http" "https") $scheme }}
  126. {{ $target = "target=\"_blank\" rel=\"noopener\"" }}
  127. {{ end }}
  128. <li>
  129. <i class="fa-li {{ $pack }} {{ $pack_prefix }}-{{ .icon }} fa-2x" aria-hidden="true"></i>
  130. <a href="{{ $link | safeURL }}" {{ $target | safeHTMLAttr }}>{{.name|markdownify|emojify|safeHTML}}</a>
  131. </li>
  132. {{ end }}
  133. </ul>
  134. {{ if and site.Params.map.provider $data.coordinates.latitude }}
  135. <div class="d-none">
  136. <input id="map-provider" value="{{ lower site.Params.map.provider }}">
  137. <input id="map-lat" value="{{ $data.coordinates.latitude }}">
  138. <input id="map-lng" value="{{ $data.coordinates.longitude }}">
  139. <input id="map-dir" value="{{ $addr_formatted }}">
  140. <input id="map-zoom" value="{{ site.Params.map.zoom | default "15" }}">
  141. <input id="map-api-key" value="{{ site.Params.map.api_key }}">
  142. </div>
  143. <div id="map"></div>
  144. {{ end }}
  145. </div>