From 13d880a05dfa851eb68d9ef7b3d843ac212adbe9 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Tue, 10 May 2022 22:21:39 +0100 Subject: [PATCH] Add image attribution from unsplash --- layouts/_default/single.html | 7 +++++++ layouts/partials/content.html | 3 ++- layouts/partials/share.html | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 11a1b70..f08cf03 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -3,6 +3,13 @@
{{ partial "content.html" . }}
+ + {{ with .Scratch.Get "unsplash_data" }} +
+ Header photo by {{ .user.name }} on Unsplash. +
+ {{ end }} + {{ partial "share.html" . }} {{ partial "related-content.html" . }} diff --git a/layouts/partials/content.html b/layouts/partials/content.html index c327a48..7b2da9c 100644 --- a/layouts/partials/content.html +++ b/layouts/partials/content.html @@ -8,9 +8,10 @@ {{ $query := querify "client_id" (getenv "UNSPLASH_ACCESS_KEY") }} {{ $unsplash_data := (getJSON "https://api.unsplash.com/photos/" $unsplash_id "?" $query )}} {{ .Scratch.Set "image" $unsplash_data.urls.regular }} + {{ .Scratch.Set "unsplash_data" $unsplash_data }} {{ end }} - + {{ end }} {{ partial "breadcrumbs/index.html" . }} diff --git a/layouts/partials/share.html b/layouts/partials/share.html index 3688a0d..8b50d2b 100644 --- a/layouts/partials/share.html +++ b/layouts/partials/share.html @@ -1,5 +1,5 @@ {{ if .Section }} -
+
Share this page