|
| 1 | +{{/* Hugo Blox: Contact */}} |
| 2 | +{{/* Documentation: https://hugoblox.com/blocks/ */}} |
| 3 | +{{/* License: https://github.com/HugoBlox/hugo-blox-builder/blob/main/LICENSE.md */}} |
| 4 | + |
| 5 | +{{/* Initialise */}} |
| 6 | +{{ $page := .wcPage }} |
| 7 | +{{ $block := .wcBlock }} |
| 8 | +{{ $autolink := default true $block.content.autolink }} |
| 9 | +{{ $data := $block.content }} |
| 10 | + |
| 11 | +{{ $columns := $block.design.columns | default "2" }} |
| 12 | + |
| 13 | +{{ with $block.content.title }} |
| 14 | + <div class="section-heading col-12 mb-3 text-center"> |
| 15 | + <h1 class="mb-0">{{ . | markdownify | emojify }}</h1> |
| 16 | + {{ with $block.content.subtitle }}<p class="mt-1">{{ . | markdownify | emojify }}</p>{{ end }} |
| 17 | + </div> |
| 18 | +{{ end }} |
| 19 | + |
| 20 | +<div class="col-12 {{if eq $columns "2"}}col-lg-8{{end}}"> |
| 21 | + {{ with $block.content.text }}<p>{{ . | emojify | $page.RenderString }}</p>{{ end }} |
| 22 | + |
| 23 | + <ul class="fa-ul"> |
| 24 | + |
| 25 | + {{ if $data.email }} |
| 26 | + <li> |
| 27 | + <i class="fa-li fas fa-envelope fa-2x" aria-hidden="true"></i> |
| 28 | + <span id="person-email"> |
| 29 | + {{- if $autolink }}<a href="mailto:{{ $data.email }}">{{ $data.email }}</a>{{ else }}{{ $data.email }}{{ end -}} |
| 30 | + </span> |
| 31 | + </li> |
| 32 | + {{ end }} |
| 33 | + |
| 34 | + {{ with $data.phone }} |
| 35 | + <li> |
| 36 | + <i class="fa-li fas fa-phone fa-2x" aria-hidden="true"></i> |
| 37 | + <span id="person-telephone"> |
| 38 | + {{- if $autolink }}<a href="tel:{{ . }}">{{ . }}</a>{{ else }}{{ . }}{{ end -}} |
| 39 | + </span> |
| 40 | + </li> |
| 41 | + {{ end }} |
| 42 | + |
| 43 | + {{ $addr_formatted := "" }}{{/* Scoping for maps. */}} |
| 44 | + {{ if $data.address.street | or $data.address.city | or $data.address.region | or $data.address.postcode | or $data.address.country }} |
| 45 | + {{ $addr_formatted = partial "functions/get_address" (dict "root" . "address" $data.address) }} |
| 46 | + <li> |
| 47 | + <i class="fa-li fas fa-map-marker fa-2x" aria-hidden="true"></i> |
| 48 | + <span id="person-2-address">{{$addr_formatted}}</span> |
| 49 | + </li> |
| 50 | + {{ end }} |
| 51 | + |
| 52 | + {{ with $data.directions }} |
| 53 | + <li> |
| 54 | + <i class="fa-li fas fa-compass fa-2x" aria-hidden="true"></i> |
| 55 | + <span>{{ . | markdownify | emojify }}</span> |
| 56 | + </li> |
| 57 | + {{ end }} |
| 58 | + |
| 59 | + {{ with $data.office_hours }} |
| 60 | + <li> |
| 61 | + <i class="fa-li fas fa-clock fa-2x" aria-hidden="true"></i> |
| 62 | + <span> |
| 63 | + {{- if not (reflect.IsSlice .)}}{{/* Support legacy string format. */}} |
| 64 | + {{- . | markdownify | emojify -}} |
| 65 | + {{else}} |
| 66 | + {{- delimit . "<br>" | markdownify | emojify -}} |
| 67 | + {{end -}} |
| 68 | + </span> |
| 69 | + </li> |
| 70 | + {{ end }} |
| 71 | + |
| 72 | + {{ with $data.appointment_url }} |
| 73 | + <li> |
| 74 | + <i class="fa-li fas fa-calendar-check fa-2x" aria-hidden="true"></i> |
| 75 | + <a href="{{ . }}" target="_blank" rel="noopener">{{ i18n "book_appointment" | default "Book an appointment" }}</a> |
| 76 | + </li> |
| 77 | + {{ end }} |
| 78 | + |
| 79 | + {{/* Contact links. */}} |
| 80 | + {{ range $data.contact_links }} |
| 81 | + {{ $pack := or .icon_pack "fas" }} |
| 82 | + {{ $pack_prefix := $pack }} |
| 83 | + {{ if in (slice "fab" "fas" "far" "fal") $pack }} |
| 84 | + {{ $pack_prefix = "fa" }} |
| 85 | + {{ end }} |
| 86 | + {{ $link := .link }} |
| 87 | + {{ $scheme := (urls.Parse $link).Scheme }} |
| 88 | + {{ $target := "" }} |
| 89 | + {{ if not $scheme }} |
| 90 | + {{ $link = .link | relLangURL }} |
| 91 | + {{ else if in (slice "http" "https") $scheme }} |
| 92 | + {{ $target = "target=\"_blank\" rel=\"noopener\"" }} |
| 93 | + {{ end }} |
| 94 | + <li> |
| 95 | + <i class="fa-li {{ $pack }} {{ $pack_prefix }}-{{ .icon }} fa-2x" aria-hidden="true"></i> |
| 96 | + <a href="{{ $link | safeURL }}" {{ $target | safeHTMLAttr }}>{{.name|markdownify|emojify|safeHTML}}</a> |
| 97 | + </li> |
| 98 | + {{ end }} |
| 99 | + |
| 100 | + </ul> |
| 101 | + |
| 102 | + {{ if and site.Params.features.map.provider $data.coordinates.latitude }} |
| 103 | + <div class="d-none"> |
| 104 | + <input id="map-2-provider" value="{{ lower site.Params.features.map.provider }}"> |
| 105 | + <input id="map-2-lat" value="{{ $data.coordinates.latitude }}"> |
| 106 | + <input id="map-2-lng" value="{{ $data.coordinates.longitude }}"> |
| 107 | + <input id="map-2-dir" value="{{ $addr_formatted }}"> |
| 108 | + <input id="map-2-zoom" value="{{ site.Params.features.map.zoom | default "15" }}"> |
| 109 | + <input id="map-2-api-key" value="{{ site.Params.features.map.api_key }}"> |
| 110 | + </div> |
| 111 | + <div id="map2"></div> |
| 112 | + {{ end }} |
| 113 | + |
| 114 | +</div> |
| 115 | + |
| 116 | +{{/* Maps */}} |
| 117 | +{{ if site.Params.features.map.provider }} |
| 118 | + {{ $js := resources.Get "js/map2.js" | js.Build (dict "format" "esm" "minify" true) }} |
| 119 | + {{- if hugo.IsProduction -}} |
| 120 | + {{- $js = $js | fingerprint "md5" -}} |
| 121 | + {{- end -}} |
| 122 | + <script src="{{ $js.RelPermalink }}" type="module"></script> |
| 123 | +{{- end -}} |
| 124 | + |
| 125 | +{{ $style := resources.Get "css/_contact2.css" }} |
| 126 | +<link rel="stylesheet" href="{{ $style.RelPermalink }}" media="print" onload="this.media='all'"> |
0 commit comments