Back to Prql

Section Testimonials

web/website/themes/prql-theme/layouts/partials/section-testimonials.html

0.13.142.0 KB
Original Source

{{ if .enable }}

{{ .title | markdownify }}

{{ range site.Data.testimonials }} {{/* Margin-top & margin-bottom are set to match Tweets. Maybe there's a better way of designing this? (and maybe we design from the stylesheet?) */}} {{ with .quote }} {{ if .link }} {{ .text }} — {{ .author }} {{ else }}

{{ .text }} — {{ .author }}

{{ end }} {{ end }} {{ with .tweet }}

{{/* The Firefox tracking protection blocks images hosted on pbs.twitter.com, see https://bugzilla.mozilla.org/show\_bug.cgi?id=1458915 So we download the images when building the website. The fetches are wrapped in try so a slow or unreachable Twitter CDN degrades to a fallback image rather than failing the whole build — resources.GetRemote otherwise fails the build on a request error such as a timeout, see https://gohugo.io/functions/resources/getremote/#error-handling */}} {{ $profileImg := .profile_image_url_https }} {{ $localImgPath := printf "cached-avatars/%s.png" .screen_name }} {{/* Transparent 1x1 GIF as the ultimate fallback, so the build never hard-depends on the network being up. */}} {{ $imageSrc := "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" }} {{ with try (resources.GetRemote "https://abs.twimg.com/sticky/default\_profile\_images/default\_profile\_normal.png") }} {{ with .Err }} {{ warnf "[section-testimonials.html] couldn't fetch default image: %s" . }} {{ else with .Value }} {{ $imageSrc = (resources.Copy "default.png" .).RelPermalink }} {{ end }} {{ end }} {{ with try (resources.GetRemote $profileImg) }} {{ with .Err }} {{ warnf "[section-testimonials.html] couldn't fetch remote image %v: %s" $profileImg . }} {{ else with .Value }} {{ $imageSrc = (resources.Copy $localImgPath .).RelPermalink }} {{ end }} {{ end }}

{{ .name }}

@{{ .screen_name }}

{{ .text }}

{{ .favorite_count }} {{ .created_at | time.Format "15:04 · Jan 2, 2006" }} Twitter

{{ end }} {{ end }}

{{ end }}