contact.html 6.0 KB

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