1
Fork 0

Allow unsplash images to be used

Oh my god Go templates are horrible!
This commit is contained in:
Jake Howard 2020-09-12 15:46:23 +01:00
parent 532baca63e
commit f311220fe2
Signed by: jake
GPG key ID: 57AFB45680EDD477
6 changed files with 18 additions and 0 deletions

View file

@ -5,6 +5,7 @@ on: [push, pull_request]
env:
FLICKR_API_KEY: ${{ secrets.FLICKR_API_KEY }}
FLICKR_USER_ID: ${{ secrets.FLICKR_USER_ID }}
UNSPLASH_API_KEY: ${{ secrets.UNSPLASH_API_KEY }}
jobs:
docker:

View file

@ -8,6 +8,7 @@ on:
env:
FLICKR_API_KEY: ${{ secrets.FLICKR_API_KEY }}
FLICKR_USER_ID: ${{ secrets.FLICKR_USER_ID }}
UNSPLASH_API_KEY: ${{ secrets.UNSPLASH_API_KEY }}
jobs:
build:

View file

@ -2,6 +2,7 @@
title: Installing Arch from scratch on Kimsufi
date: 2020-08-29
tags: [arch, linux, self-hosting]
image: unsplash:Tjbk79TARiE
---
Recently, I bought myself a new server from [Kimsufi](https://kimsufi.com/), to function as an off-site backup server. And after fighting with both their management interface and customer services, I finally got it booted. Kimsufi have a respectable list of OS options, however not especially recent. The latest version of Ubuntu they have is 16.04, and the Arch installer is based on an image from 2018.

View file

@ -3,6 +3,11 @@
{{ if hasPrefix .Params.image "resource:" }}
{{ $resource := .Resources.GetMatch (replace .Params.image "resource:" "") }}
{{ .Scratch.Set "image" ($resource.Resize "2000x").RelPermalink }}
{{ else if hasPrefix .Params.image "unsplash:" }}
{{ $unsplash_id := replace .Params.image "unsplash:" "" }}
{{ $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.full }}
{{ end }}
<div class="mb-3 image header-image" data-image='{{ .Scratch.Get "image" }}'></div>

View file

@ -6,6 +6,11 @@
{{ if hasPrefix .Params.image "resource:" }}
{{ $resource := .Resources.GetMatch (replace .Params.image "resource:" "") }}
{{ .Scratch.Set "image" ($resource.Resize "500x").RelPermalink }}
{{ else if hasPrefix .Params.image "unsplash:" }}
{{ $unsplash_id := replace .Params.image "unsplash:" "" }}
{{ $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.thumb }}
{{ end }}
<div class="image" data-image='{{ .Scratch.Get "image" }}'></div>
</a>

View file

@ -3,6 +3,11 @@
{{ if hasPrefix .Params.image "resource:" }}
{{ $resource := .Resources.GetMatch (replace .Params.image "resource:" "") }}
{{ .Scratch.Set "image" ($resource.Fill "800x418").Permalink }}
{{ else if hasPrefix .Params.image "unsplash:" }}
{{ $unsplash_id := replace .Params.image "unsplash:" "" }}
{{ $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.small }}
{{ end }}
{{ end }}