diff options
author | nodejh <jianghangscu@gmail.com> | 2021-02-25 16:41:02 +0300 |
---|---|---|
committer | nodejh <jianghangscu@gmail.com> | 2021-02-25 16:41:02 +0300 |
commit | de08159806dd7763e2107e6effc2cf2fa57a067b (patch) | |
tree | 1b4349273fb56faf7efb2275f6c721296ba04333 | |
parent | 180c9c61d675fb73d9933e91c27f2a60584c8a2b (diff) |
feat: add cover imagesfeature/cover-image
-rw-r--r-- | layouts/index.html | 47 | ||||
-rw-r--r-- | static/css/style.css | 20 |
2 files changed, 62 insertions, 5 deletions
diff --git a/layouts/index.html b/layouts/index.html index aa4d823..a56079f 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -7,7 +7,7 @@ {{ range $paginator.Pages }} {{ $title := .Title }} {{ $summary := .Summary }} - <section class="item"> + <!-- <section class="item"> <div> <h1 class="title"><a href='{{ .RelPermalink }}'>{{ $title }}</a></h1> <div class="date">{{ .Date.Format "Jan 2" }}</div> @@ -15,8 +15,6 @@ <div class="summary">{{ $summary | plainify | htmlUnescape }}</div> - - {{ with .Resources.ByType "image" }} {{ $image := index . 1 }} {{ range . }} @@ -33,6 +31,49 @@ <img src="{{ $image.RelPermalink }}" alt="{{ $title }}"> </div> {{ end }} + </section> --> + + + <section class="item"> + + {{ if .Resources.ByType "image" }} + <!-- with cover image --> + + {{ $images := .Resources.ByType "image" }} + {{ $image := index $images 1 }} + {{ range .Resources.ByType "image" }} + {{ if eq .Name "images/cover.png" }} + {{ $image = . }} + {{ else if eq .Name "images/cover.jpg" }} + {{ $image = . }} + {{ else if eq .Name "images/cover.jpeg" }} + {{ $image = . }} + {{ end }} + {{ end }} + + + <div class="left"> + <h1 class="title"><a href='{{ .RelPermalink }}'>{{ $title }}</a></h1> + <div class="summary">{{ $summary | plainify | htmlUnescape }}</div> + </div> + + <div class="right"> + <img src="{{ $image.RelPermalink }}" alt="{{ $title }}"> + </div> + {{ else }} + <!-- no cover image --> + + <div> + <h1 class="title"><a href='{{ .RelPermalink }}'>{{ $title }}</a></h1> + <div class="date">{{ .Date.Format "Jan 2" }}</div> + </div> + + <div class="summary">{{ $summary | plainify | htmlUnescape }}</div> + + {{ end }} + + + </section> {{ end }} diff --git a/static/css/style.css b/static/css/style.css index 475d53f..3444cba 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -224,7 +224,7 @@ nav.navigation a.button { /* index post list */ -#list-page .item { +/* #list-page .item { margin: 48px 0 0 0; } @@ -252,7 +252,7 @@ nav.navigation a.button { } #list-page .summary { - color: #6a737d; + color: #8c8c8c; margin-top: 12px; } @@ -265,4 +265,20 @@ nav.navigation a.button { #list-page .cover img { width: 100%; text-align: center; +} */ + +#list-page .item { + display: inline-block; +} + +#list-page .item .left { + float: left; +} +#list-page .item .right { + float: right; + width: 200px; + min-width: 200px; + max-height: 150px; + border-radius: 4px; + overflow: hidden; }
\ No newline at end of file |