mirror of
https://github.com/gohugoio/hugo.git
synced 2026-08-24 15:28:54 +00:00
Add srcset to the showcase screenshots
This commit is contained in:
BIN
Binary file not shown.
|
After Width: | Height: | Size: 77 KiB |
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
BIN
Binary file not shown.
|
Before Width: | Height: | Size: 34 KiB |
BIN
Binary file not shown.
|
Before Width: | Height: | Size: 67 KiB |
@@ -7,8 +7,14 @@
|
||||
{{ range $p := first 10 (where .Site.RegularPages "Section" "showcase") }}
|
||||
{{ $img := (.Resources.ByType "image").GetMatch "*featured*" }}
|
||||
{{ with $img }}
|
||||
{{ $img := .Fill "512x256 top" }}
|
||||
<a href="{{ $p.RelPermalink}}" class="tile lazyload cover dib f4 h5 ml1 mr4 bg-black relative mw-100 shadow-5" style="width:{{ $img.Width }}px;height: {{ $img.Height }}" data-bg="{{ $img.RelPermalink }}">{{/* data-bg uses a lazyload script to load the actual background image. It is located here: themes/gohugoioTheme/src/js/lazysizes.js */}}
|
||||
{{ $big := .Fill "1024x512 top" }}
|
||||
{{ $small := $big.Resize "512x" }}
|
||||
<a href="{{ $p.RelPermalink}}" class="tile lazyload cover dib f4 h5 ml1 mr4 bg-black relative mw-100 shadow-5" style="width:{{ $small.Width }}px;"
|
||||
data-bg="{{ $img.RelPermalink }}"
|
||||
data-sizes="auto"
|
||||
data-srcset="{{ $small.RelPermalink }} 1x,
|
||||
{{ $big.RelPermalink }} 2x" data-src="small"
|
||||
>
|
||||
{{with $p.Title}}
|
||||
<div class="details absolute bottom-0 f3-ns f4 left-0 o-0 right-0 top-0">
|
||||
<div class="absolute bottom-0 pa2 tc white">
|
||||
|
||||
@@ -22,12 +22,16 @@
|
||||
|
||||
|
||||
{{define "showcase_items"}}
|
||||
<a href="{{.Permalink}}" class="b--moon-gray ba bg-animate bg-white db flex-auto-ns hover-bg-near-white mb3 mr3 w-100 w-30-l">
|
||||
<a href="{{.Permalink}}" class="b--moon-gray ba bg-animate bg-white db flex-auto-ns hover-bg-near-white mb3 mr3 w-100 w-30-l" style="max-width: 1024px;">
|
||||
<div class="flex flex-column black h-100 mb2 pa3 pa4-l">
|
||||
{{ $img := (.Resources.ByType "image").GetMatch "*featured*" }}
|
||||
{{ with $img }}
|
||||
{{ $img := .Fill "600x300 top" }}
|
||||
<img src="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYwMCIgaGVpZ2h0PSI5MDAiIHZpZXdCb3g9IjAgMCAxNjAwIDkwMCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj48dGl0bGU+UmVjdGFuZ2xlPC90aXRsZT48ZGVzYz5DcmVhdGVkIHdpdGggU2tldGNoLjwvZGVzYz48ZyBpZD0iUGFnZS0xIiBzdHJva2U9Im5vbmUiIHN0cm9rZS13aWR0aD0iMSIgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj48cmVjdCBpZD0iUmVjdGFuZ2xlIiB4PSIwIiB5PSIwIiB3aWR0aD0iMTYwMCIgaGVpZ2h0PSI5MDAiLz48L2c+PC9zdmc+" data-src="{{ .RelPermalink }}" class="grow img lazyload" />
|
||||
{{ $big := .Fill "1024x512 top" }}
|
||||
{{ $small := $big.Resize "512x" }}
|
||||
<img src="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYwMCIgaGVpZ2h0PSI5MDAiIHZpZXdCb3g9IjAgMCAxNjAwIDkwMCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj48dGl0bGU+UmVjdGFuZ2xlPC90aXRsZT48ZGVzYz5DcmVhdGVkIHdpdGggU2tldGNoLjwvZGVzYz48ZyBpZD0iUGFnZS0xIiBzdHJva2U9Im5vbmUiIHN0cm9rZS13aWR0aD0iMSIgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj48cmVjdCBpZD0iUmVjdGFuZ2xlIiB4PSIwIiB5PSIwIiB3aWR0aD0iMTYwMCIgaGVpZ2h0PSI5MDAiLz48L2c+PC9zdmc+"
|
||||
data-sizes="auto"
|
||||
data-srcset="{{ $small.RelPermalink }} 1x,
|
||||
{{ $big.RelPermalink }} 2x" data-bg="{{ $small.RelPermalink }}" class="grow img lazyload" style="display: block; width: 100%; height: auto;" />
|
||||
{{end}}
|
||||
<div style="margin-top:auto;">{{/* the margin aligns to the bottom */}}
|
||||
<h2 class="dib f3 mt4">
|
||||
|
||||
@@ -35,8 +35,9 @@ Showcase: {{ .Title }}
|
||||
{{define "main-column"}}
|
||||
{{ $img := (.Resources.ByType "image").GetMatch "*featured*" }}
|
||||
{{ with $img }}
|
||||
{{ $img := .Resize "940x" }}
|
||||
<img src="{{ $img.RelPermalink }}" alt="{{ $img.Title }}" width="{{ $img.Width }}" class="mw-100 b--light-gray ba">
|
||||
{{ $big := .Fill "1024x512 top" }}
|
||||
{{ $small := $big.Resize "512x" }}
|
||||
<img srcset="{{ $small.RelPermalink }} 1x, {{ $big.RelPermalink }} 2x" alt="{{ $img.Title }}" width="{{ $big.Width }}" class="mw-100 b--light-gray ba">
|
||||
{{ end }}
|
||||
<div class="mid-gray nested-copy-line-height nested-img nested-links">
|
||||
{{with .Params.byline }}
|
||||
|
||||
Reference in New Issue
Block a user