diff --git a/layouts/partials/head.html b/layouts/partials/head.html
index c694f106..908d6eb7 100644
--- a/layouts/partials/head.html
+++ b/layouts/partials/head.html
@@ -72,7 +72,3 @@
{{ partial "extra-head.html" . }}
{{- end }}
-
-{{- if .Site.GoogleAnalytics }}
- {{ template "_internal/google_analytics.html" . }}
-{{- end}}
diff --git a/layouts/shortcodes/openlibrary.html b/layouts/shortcodes/openlibrary.html
index 774dd4f7..cb1fb56d 100644
--- a/layouts/shortcodes/openlibrary.html
+++ b/layouts/shortcodes/openlibrary.html
@@ -14,39 +14,65 @@
{{ if not $key }}
{{ $query := (dict "type" "/type/edition" "isbn_13" $isbn) | jsonify }}
- {{ $thing := getJSON (printf "https://openlibrary.org/api/things?query=%s" ($query)) }}
- {{ if and (eq $thing.status "ok") (ge (len $thing.result) 1) }}
- {{ $key = index $thing.result 0 }}
+ {{ with resources.GetRemote (printf "https://openlibrary.org/api/things?query=%s" ($query)) }}
+ {{ with .Err }}
+ {{ errorf "Error grabbing Thing from OpenLibrary: %v" . }}
+ {{ else }}
+ {{ $thing := .Content | transform.Unmarshal }}
+ {{ if and (eq $thing.status "ok") (ge (len $thing.result) 1) }}
+ {{ $key = index $thing.result 0 }}
+ {{ end }}
+ {{ end }}
+ {{ else }}
+ {{ warnf "Failed to fetch ISBN data from OpenLibrary: %s" $isbn }}
{{ end }}
{{ end}}
{{ if $key }}
- {{ $bookObj := getJSON (printf "https://openlibrary.org/api/get?key=%s" $key) }}
- {{ if eq $bookObj.status "ok" }}
- {{ $isbn = index $bookObj.result.isbn_13 0 }}
+ {{ with resources.GetRemote (printf "https://openlibrary.org/api/get?key=%s" $key) }}
+ {{ with .Err }}
+ {{ errorf "Error grabbing Book data from OpenLibrary: %v" . }}
+ {{ else }}
+ {{ $bookObj := .Content | transform.Unmarshal }}
+ {{ if eq $bookObj.status "ok" }}
+ {{ $isbn = index $bookObj.result.isbn_13 0 }}
- {{ $authors := slice }}
- {{ range $bookObj.result.authors }}
- {{ $authorObj := getJSON (printf "https://openlibrary.org/api/get?key=%s" .key) }}
- {{ if eq $authorObj.status "ok" }}
- {{ $authors = $authors | append (dict "name" $authorObj.result.name "url" (printf "https://openlibrary.org%s" $authorObj.result.key)) }}
+ {{ $authors := slice }}
+ {{ range $bookObj.result.authors }}
+ {{ with resources.GetRemote (printf "https://openlibrary.org/api/get?key=%s" .key) }}
+ {{ with .Err }}
+ {{ errorf "Error grabbing Author data from OpenLibrary: %v" . }}
+ {{ else }}
+ {{ $authorObj := .Content | transform.Unmarshal }}
+ {{ if eq $authorObj.status "ok" }}
+ {{ $authors = $authors | append (dict "name" $authorObj.result.name "url" (printf "https://openlibrary.org%s" $authorObj.result.key)) }}
+ {{ end }}
+ {{ end }}
+ {{ else }}
+ {{ warnf "Failed to fetch Author data from OpenLibrary: %s" .key }}
+ {{ end }}
+ {{ end }}
+
+ {{ $coverURL := (printf "https://covers.openlibrary.org/b/isbn/%s-M.jpg" $isbn)}}
+ {{ if not $isbn }}
+ {{ $coverURL = printf "https://covers.openlibrary.org/b/id/%.0f-M.jpg" (index $bookObj.result.covers 0) }}
+ {{ end }}
+
+ {{- $bookFilename := replaceRE `[^a-z]+` "-" (lower $bookObj.result.title) -}}
+ {{- $coverPath := replaceRE `(\.md)?$` (printf "/%s.jpg" $bookFilename) $path -}}
+ {{ $cover := "" }}
+ {{ with resources.GetRemote $coverURL }}
+ {{ with .Err }}
+ {{ else }}
+ {{ $cover = .Content | resources.FromString $coverPath }}
+ {{ end }}
+ {{ end }}
+
+ {{ $book := dict "title" $bookObj.result.title "authors" $authors "url" (printf "https://openlibrary.org%s" $key) "cover" $cover }}
+ {{ partial "book.html" $book }}
{{ end }}
{{ end }}
-
- {{ $coverURL := (printf "https://covers.openlibrary.org/b/isbn/%s-M.jpg" $isbn)}}
- {{ if not $isbn }}
- {{ $coverURL = printf "https://covers.openlibrary.org/b/id/%.0f-M.jpg" (index $bookObj.result.covers 0) }}
- {{ end }}
-
- {{ $cover := "" }}
- {{ with resources.GetRemote $coverURL }}
- {{ with .Err }}
- {{ else }}
- {{ $cover = .Content | resources.FromString (replaceRE `\.md$` ".jpg" $path) }}
- {{ end }}
- {{ end }}
-
- {{ $book := dict "title" $bookObj.result.title "authors" $authors "url" (printf "https://openlibrary.org%s" $key) "cover" $cover }}
- {{ partial "book.html" $book }}
+ {{ else }}
+ {{ warnf "Failed to fetch Book data data from OpenLibrary: %s" $key }}
{{ end }}
{{ end }}