contact.html 5.8 KB

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