diff options
Diffstat (limited to 'layouts/book')
| -rw-r--r-- | layouts/book/list.html | 33 | ||||
| -rw-r--r-- | layouts/book/single.html | 15 |
2 files changed, 47 insertions, 1 deletions
diff --git a/layouts/book/list.html b/layouts/book/list.html new file mode 100644 index 0000000..628d8b8 --- /dev/null +++ b/layouts/book/list.html | |||
| @@ -0,0 +1,33 @@ | |||
| 1 | {{ define "main" }} | ||
| 2 | <article> | ||
| 3 | <h1>{{ .Title }}</h1> | ||
| 4 | {{ if .Content }} | ||
| 5 | <p>{{- .Content -}}</p> | ||
| 6 | {{ end }} | ||
| 7 | <section> | ||
| 8 | {{ if .IsSection }} | ||
| 9 | {{ range sort (.Paginator 3).Pages "Date" "desc" }} | ||
| 10 | {{ if ne .Layout "list" }} | ||
| 11 | <div>{{ .Render "summary" }}</div> | ||
| 12 | {{ end }} | ||
| 13 | {{ end }} | ||
| 14 | {{ else }} | ||
| 15 | {{ $metric := .Params.sortby }} | ||
| 16 | {{ $direction := "asc" }} | ||
| 17 | {{ if eq .Params.sortby "rating" }} | ||
| 18 | {{ $direction = "desc" }} | ||
| 19 | {{ end }} | ||
| 20 | {{ $pages := (where .Site.RegularPages "Type" "book") }} | ||
| 21 | {{ $pages = (where $pages "Layout" "!=" "list")}} | ||
| 22 | {{ if eq $direction "desc" }} | ||
| 23 | {{ $pages = (sort ($pages.ByParam $metric).Reverse) }} | ||
| 24 | {{ else }} | ||
| 25 | {{ $pages = (sort ($pages.ByParam $metric)) }} | ||
| 26 | {{ end }} | ||
| 27 | {{ range $pages }} | ||
| 28 | <div>{{ .Render "summary" }}</div> | ||
| 29 | {{ end }} | ||
| 30 | {{ end }} | ||
| 31 | </section> | ||
| 32 | </article> | ||
| 33 | {{ end }} \ No newline at end of file | ||
diff --git a/layouts/book/single.html b/layouts/book/single.html index 3ffb236..0bbd265 100644 --- a/layouts/book/single.html +++ b/layouts/book/single.html | |||
| @@ -4,7 +4,20 @@ | |||
| 4 | <h4>{{ .Params.author }}</h4> | 4 | <h4>{{ .Params.author }}</h4> |
| 5 | <h6>{{ .Date | time.Format ":date_full" }}</h6> | 5 | <h6>{{ .Date | time.Format ":date_full" }}</h6> |
| 6 | {{ if isset .Params "image" }} | 6 | {{ if isset .Params "image" }} |
| 7 | <img src="{{ .Params.image }}" alt="Book cover of the book {{ .Title }}" /> | 7 | {{ with resources.GetRemote .Params.image }} |
| 8 | {{ with .Err }} | ||
| 9 | {{ errorf "%s" . }} | ||
| 10 | {{ else }} | ||
| 11 | <img | ||
| 12 | src="{{ .RelPermalink }}" | ||
| 13 | width="{{ .Width }}" | ||
| 14 | height="{{ .Height }}" | ||
| 15 | alt="Book cover of the book {{ .Title }}" | ||
| 16 | /> | ||
| 17 | {{ end }} | ||
| 18 | {{ else }} | ||
| 19 | {{ errorf "unable to get remote resource %q" .Params.image }} | ||
| 20 | {{ end }} | ||
| 8 | {{ end }} | 21 | {{ end }} |
| 9 | {{ if isset .Params "amazon" }} | 22 | {{ if isset .Params "amazon" }} |
| 10 | <p> | 23 | <p> |
