diff options
Diffstat (limited to 'layouts/book')
-rw-r--r-- | layouts/book/list.html | 31 | ||||
-rw-r--r-- | layouts/book/single.html | 40 | ||||
-rw-r--r-- | layouts/book/summary.html | 29 |
3 files changed, 100 insertions, 0 deletions
diff --git a/layouts/book/list.html b/layouts/book/list.html new file mode 100644 index 0000000..25976dd --- /dev/null +++ b/layouts/book/list.html | |||
@@ -0,0 +1,31 @@ | |||
1 | {{ define "main" }} | ||
2 | <h1>{{ .Title }}</h1> | ||
3 | {{ if .Content }} | ||
4 | <p>{{- .Content -}}</p> | ||
5 | {{ end }} | ||
6 | <section> | ||
7 | {{ if .IsSection }} | ||
8 | {{ range sort .Pages "Date" "desc" }} | ||
9 | {{ if ne .Layout "list" }} | ||
10 | <div>{{ .Render "summary" }}</div> | ||
11 | {{ end }} | ||
12 | {{ end }} | ||
13 | {{ else }} | ||
14 | {{ $metric := .Params.sortby }} | ||
15 | {{ $direction := "asc" }} | ||
16 | {{ if eq .Params.sortby "rating" }} | ||
17 | {{ $direction = "desc" }} | ||
18 | {{ end }} | ||
19 | {{ $pages := (where .Site.RegularPages "Type" "book") }} | ||
20 | {{ $pages = (where $pages "Layout" "!=" "list")}} | ||
21 | {{ if eq $direction "desc" }} | ||
22 | {{ $pages = (sort ($pages.ByParam $metric).Reverse) }} | ||
23 | {{ else }} | ||
24 | {{ $pages = (sort ($pages.ByParam $metric)) }} | ||
25 | {{ end }} | ||
26 | {{ range $pages }} | ||
27 | <div>{{ .Render "summary" }}</div> | ||
28 | {{ end }} | ||
29 | {{ end }} | ||
30 | </section> | ||
31 | {{ end }} \ No newline at end of file | ||
diff --git a/layouts/book/single.html b/layouts/book/single.html new file mode 100644 index 0000000..baedf32 --- /dev/null +++ b/layouts/book/single.html | |||
@@ -0,0 +1,40 @@ | |||
1 | {{ define "main" }} | ||
2 | <hgroup> | ||
3 | <h1>{{ .Title }}</h1> | ||
4 | <h6>{{ .Date | time.Format ":date_full" }}</h6> | ||
5 | </hgroup> | ||
6 | {{ if isset .Params "image" }} | ||
7 | {{ with resources.GetRemote .Params.image }} | ||
8 | {{ with .Err }} | ||
9 | {{ errorf "%s" . }} | ||
10 | {{ else }} | ||
11 | {{ $image := . }} | ||
12 | {{ $image := $image.Resize "250x" }} | ||
13 | <img | ||
14 | src="{{ $image.RelPermalink }}" | ||
15 | width="{{ $image.Width }}" | ||
16 | height="{{ $image.Height }}" | ||
17 | alt="Book cover of the book {{ .Title }}" | ||
18 | /> | ||
19 | {{ end }} | ||
20 | {{ else }} | ||
21 | {{ errorf "unable to get remote resource %q" .Params.image }} | ||
22 | {{ end }} | ||
23 | {{ end }} | ||
24 | {{ if isset .Params "amazon" }} | ||
25 | <p> | ||
26 | <a href="{{ .Params.amazon }}" target="_blank">amazon</a> | ||
27 | </p> | ||
28 | {{ end }} | ||
29 | <div> | ||
30 | <p>Rating: </p> | ||
31 | {{ if isset .Params "rating" }} | ||
32 | {{ $rating := .Params.rating }} | ||
33 | {{ range $i, $num := (seq $rating) }} | ||
34 | ⭐ | ||
35 | {{ end }} | ||
36 | {{ else }} | ||
37 | <p>N/A</p> | ||
38 | {{ end }} | ||
39 | </div> | ||
40 | {{ end }} \ No newline at end of file | ||
diff --git a/layouts/book/summary.html b/layouts/book/summary.html new file mode 100644 index 0000000..900fb87 --- /dev/null +++ b/layouts/book/summary.html | |||
@@ -0,0 +1,29 @@ | |||
1 | <section class="flex row gap-1"> | ||
2 | {{ with resources.GetRemote .Params.image }} | ||
3 | {{ with .Err }} | ||
4 | {{ errorf "%s" . }} | ||
5 | {{ else }} | ||
6 | {{ $image := . }} | ||
7 | {{ $image := $image.Resize "150x" }} | ||
8 | <img | ||
9 | src="{{ $image.RelPermalink }}" | ||
10 | width="{{ $image.Width }}" | ||
11 | height="{{ $image.Height }}" | ||
12 | alt="Book cover of the book {{ .Title }}" | ||
13 | /> | ||
14 | {{ end }} | ||
15 | {{ else }} | ||
16 | {{ errorf "unable to get remote resource %q" .Params.image }} | ||
17 | {{ end }} | ||
18 | <hgroup> | ||
19 | <h3 class="f3 near-black"> | ||
20 | <a href="{{ .RelPermalink }}" class="link black dim"> | ||
21 | {{ .Title }} | ||
22 | </a> | ||
23 | </h3> | ||
24 | <p>Rating: {{ .Params.rating }} / 5</p> | ||
25 | {{ with .Params.last_read }} | ||
26 | <p>Last Read: {{ . | time.Format ":date_full" }}</p> | ||
27 | {{ end }} | ||
28 | </hgroup> | ||
29 | </section> | ||