contact.html 5.4 KB

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