1
Fork 0

Add image attribution from unsplash

This commit is contained in:
Jake Howard 2022-05-10 22:21:39 +01:00
parent ff5e1ff4bf
commit 13d880a05d
Signed by: jake
GPG key ID: 57AFB45680EDD477
3 changed files with 10 additions and 2 deletions

View file

@ -3,6 +3,13 @@
<div class="container"> <div class="container">
{{ partial "content.html" . }} {{ partial "content.html" . }}
</div> </div>
{{ with .Scratch.Get "unsplash_data" }}
<div class="container text-center my-4">
<small><a href="#header">Header</a> photo by <a href="{{ .user.links.html }}">{{ .user.name }}</a> on <a href="{{ .links.html }}">Unsplash</a>.</small>
</div>
{{ end }}
{{ partial "share.html" . }} {{ partial "share.html" . }}
{{ partial "related-content.html" . }} {{ partial "related-content.html" . }}
</div> </div>

View file

@ -8,9 +8,10 @@
{{ $query := querify "client_id" (getenv "UNSPLASH_ACCESS_KEY") }} {{ $query := querify "client_id" (getenv "UNSPLASH_ACCESS_KEY") }}
{{ $unsplash_data := (getJSON "https://api.unsplash.com/photos/" $unsplash_id "?" $query )}} {{ $unsplash_data := (getJSON "https://api.unsplash.com/photos/" $unsplash_id "?" $query )}}
{{ .Scratch.Set "image" $unsplash_data.urls.regular }} {{ .Scratch.Set "image" $unsplash_data.urls.regular }}
{{ .Scratch.Set "unsplash_data" $unsplash_data }}
{{ end }} {{ end }}
<img class="mb-3 header-image" src='{{ .Scratch.Get "image" }}' alt="" decoding="async" referrerpolicy="no-referrer" /> <img class="mb-3 header-image" id="header" src='{{ .Scratch.Get "image" }}' alt="" decoding="async" referrerpolicy="no-referrer" />
{{ end }} {{ end }}
{{ partial "breadcrumbs/index.html" . }} {{ partial "breadcrumbs/index.html" . }}

View file

@ -1,5 +1,5 @@
{{ if .Section }} {{ if .Section }}
<div class="container mt-5 text-center"> <div class="container text-center">
<small>Share this page</small> <small>Share this page</small>
<div class="shareon" data-title="{{ .Title }}" data-url="{{ .Permalink }}"> <div class="shareon" data-title="{{ .Title }}" data-url="{{ .Permalink }}">
<a class="facebook" title="Share on Facebook"></a> <a class="facebook" title="Share on Facebook"></a>