From 679aa7890f869a16eebba9a05d2598c1c926d1d6 Mon Sep 17 00:00:00 2001 From: JP Hastings-Spital Date: Tue, 5 Mar 2024 09:06:53 +0000 Subject: [PATCH] Add two quotes & fix books --- assets/scss/_single.scss | 19 +------- content/notes/adventure.md | 10 ++++ content/notes/good-morning.md | 10 ++++ .../twitter/1493190997127438337/index.md | 8 ---- layouts/partials/book.html | 47 ++++++++++++------- layouts/shortcodes/openlibrary.html | 25 +++++----- 6 files changed, 67 insertions(+), 52 deletions(-) create mode 100644 content/notes/adventure.md create mode 100644 content/notes/good-morning.md delete mode 100644 content/notes/twitter/1493190997127438337/index.md diff --git a/assets/scss/_single.scss b/assets/scss/_single.scss index 80d6aebe..66e9d392 100644 --- a/assets/scss/_single.scss +++ b/assets/scss/_single.scss @@ -285,23 +285,8 @@ height: auto; } - .authors { - &:has(a)::before { - content: ' by '; - } - a { - &::after { - content: ', '; - } - - &:nth-last-child(2)::after { - content: ', and '; - } - - &:last-child::after { - content: ''; - } - } + .authors.list { + display:block; } } diff --git a/content/notes/adventure.md b/content/notes/adventure.md new file mode 100644 index 00000000..4ba9fa2b --- /dev/null +++ b/content/notes/adventure.md @@ -0,0 +1,10 @@ +--- +title: "Adventure" +date: 2022-01-29T10:49:39Z +tags: +- quote +--- + +> \[They] flock, beckoned by adventure \[…] it calls to those who care more for living than for their lives. + +From {{< openlibrary "9781534430990" false >}}. diff --git a/content/notes/good-morning.md b/content/notes/good-morning.md new file mode 100644 index 00000000..581bc77a --- /dev/null +++ b/content/notes/good-morning.md @@ -0,0 +1,10 @@ +--- +title: "Good morning" +date: 2021-11-21T20:50:00Z +tags: +- quote +--- + +What a beautiful quote from {{< openlibrary "9781786699602" false >}}: + +> \[…] greeting even our dearest with abbreviations like ‘Good morning’ when the true thought in our breast is ‘Every day you step into my life, you make it brighter, and if you left the world, something in me would starve for you forever, as when some barrier rises to shade a plant, which still has light enough to grow some but will never again taste the unbroken sun.’ diff --git a/content/notes/twitter/1493190997127438337/index.md b/content/notes/twitter/1493190997127438337/index.md deleted file mode 100644 index 9a3f4f60..00000000 --- a/content/notes/twitter/1493190997127438337/index.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -date: "2022-02-14T11:50:50Z" -tags: -- imported -- from-twitter -in_reply_to: ../1493190833918644224 ---- -[@mhudack](https://twitter.com/mhudack) No collaboration that I know of though ☹️ diff --git a/layouts/partials/book.html b/layouts/partials/book.html index a9a82fc9..b17d31e6 100644 --- a/layouts/partials/book.html +++ b/layouts/partials/book.html @@ -1,17 +1,32 @@ -
- - {{ $title := .title }} - {{ with .cover }} - The cover of the book {{ $title }} - {{ end}} - +{{- define "partials/author-list.html" -}} + {{- $authors := . -}} + {{- if and (ne $authors nil) (gt (len $authors) 0) -}} + + {{ " by " }} + {{- range $i, $a := $authors -}} + {{- if and (ne $i 0) (eq (add $i 1) (len $authors)) -}}and {{ end -}} + {{ $a.name }} + {{- if ne (add $i 1) (len $authors) -}}, {{ end -}} + {{- end -}} + + {{- end -}} +{{- end -}} -
- {{ .title }}
- - {{ range .authors }} - {{ .name }} - {{ end }} - -
-
+{{- if .cover -}} +
+ + {{- $title := .title -}} + {{- with .cover -}} + The cover of the book {{ $title }} + {{- end -}} + + +
+ {{ .title }} + {{- partial "partials/author-list.html" .authors -}} +
+
+{{- else -}} + {{ .title }} + {{- partial "partials/author-list.html" .authors -}} +{{- end -}} diff --git a/layouts/shortcodes/openlibrary.html b/layouts/shortcodes/openlibrary.html index cb1fb56d..b76f3934 100644 --- a/layouts/shortcodes/openlibrary.html +++ b/layouts/shortcodes/openlibrary.html @@ -1,6 +1,7 @@ {{ $path := .Page.Path }} {{ $isbn := "" }} {{ $key := "" }} +{{ $showCover := ne (.Get 1) false }} {{ with .Get 0 }} {{ if eq (len .) 13 }} @@ -53,18 +54,20 @@ {{ 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 }} + {{ if $showCover }} + {{ $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 -}} + {{ with resources.GetRemote $coverURL }} + {{ with .Err }} + {{ else }} + {{ $cover = .Content | resources.FromString $coverPath }} + {{ end }} {{ end }} {{ end }}