mirror of
https://github.com/CaiJimmy/hugo-theme-stack.git
synced 2025-04-29 03:53:30 +08:00
refactor(list): use article/components/header inside default.html
This commit is contained in:
parent
810266df31
commit
d9bec10b49
@ -1,35 +1,4 @@
|
|||||||
{{ $image := partialCached "helper/image" (dict "Context" . "Type" "articleList") .RelPermalink "articleList" }}
|
{{ $image := partialCached "helper/image" (dict "Context" . "Type" "articleList") .RelPermalink "articleList" }}
|
||||||
<article class="{{ if $image.exists }}has-image{{ end }}">
|
<article class="{{ if $image.exists }}has-image{{ end }}">
|
||||||
{{ if $image.exists }}
|
{{ partial "article/components/header" . }}
|
||||||
<div class="article-image">
|
|
||||||
<a href="{{ .RelPermalink }}">
|
|
||||||
{{ if $image.resource }}
|
|
||||||
{{- $Permalink := $image.resource.RelPermalink -}}
|
|
||||||
{{- $Width := $image.resource.Width -}}
|
|
||||||
{{- $Height := $image.resource.Height -}}
|
|
||||||
{{- $Srcset := "" -}}
|
|
||||||
|
|
||||||
{{- if (default true .Page.Site.Params.imageProcessing.cover.enabled) -}}
|
|
||||||
{{- $thumbnail := $image.resource.Fill "800x250" -}}
|
|
||||||
{{- $thumbnailRetina := $image.resource.Fill "1600x500" -}}
|
|
||||||
{{- $Srcset = printf "%s 800w, %s 1600w" $thumbnail.RelPermalink $thumbnailRetina.RelPermalink -}}
|
|
||||||
{{- $Permalink = $thumbnail.RelPermalink -}}
|
|
||||||
{{- $Width = $thumbnail.Width -}}
|
|
||||||
{{- $Height = $thumbnail.Height -}}
|
|
||||||
{{- end -}}
|
|
||||||
|
|
||||||
<img src="{{ $Permalink }}"
|
|
||||||
{{ with $Srcset }}srcset="{{ . }}"{{ end }}
|
|
||||||
width="{{ $Width }}"
|
|
||||||
height="{{ $Height }}"
|
|
||||||
loading="lazy"
|
|
||||||
alt="Featured image of post {{ .Title }}" />
|
|
||||||
{{ else }}
|
|
||||||
<img src="{{ $image.permalink }}" loading="lazy" alt="Featured image of post {{ .Title }}" />
|
|
||||||
{{ end }}
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
{{ end }}
|
|
||||||
|
|
||||||
{{ partialCached "article/components/details" . .RelPermalink }}
|
|
||||||
</article>
|
</article>
|
@ -2,26 +2,32 @@
|
|||||||
{{- $image := partialCached "helper/image" (dict "Context" . "Type" "article") .RelPermalink "article" -}}
|
{{- $image := partialCached "helper/image" (dict "Context" . "Type" "article") .RelPermalink "article" -}}
|
||||||
{{ if $image.exists }}
|
{{ if $image.exists }}
|
||||||
<div class="article-image">
|
<div class="article-image">
|
||||||
{{ if $image.resource }}
|
<a href="{{ .RelPermalink }}">
|
||||||
{{- if (default true .Site.Params.imageProcessing.cover.enabled) -}}
|
{{ if $image.resource }}
|
||||||
{{- $tablet := $image.resource.Resize "1024x" -}}
|
{{- $Permalink := $image.resource.RelPermalink -}}
|
||||||
{{- $desktop := $image.resource.Resize "2000x" -}}
|
{{- $Width := $image.resource.Width -}}
|
||||||
<img srcset="{{ $tablet.RelPermalink }} 1024w, {{ $desktop.RelPermalink }} 2000w"
|
{{- $Height := $image.resource.Height -}}
|
||||||
src="{{ $desktop.RelPermalink }}"
|
{{- $Srcset := "" -}}
|
||||||
width="{{ $image.resource.Width }}"
|
|
||||||
height="{{ $image.resource.Height }}"
|
{{- if (default true .Page.Site.Params.imageProcessing.cover.enabled) -}}
|
||||||
|
{{- $thumbnail := $image.resource.Fill "800x250" -}}
|
||||||
|
{{- $thumbnailRetina := $image.resource.Fill "1600x500" -}}
|
||||||
|
{{- $Srcset = printf "%s 800w, %s 1600w" $thumbnail.RelPermalink $thumbnailRetina.RelPermalink -}}
|
||||||
|
{{- $Permalink = $thumbnail.RelPermalink -}}
|
||||||
|
{{- $Width = $thumbnail.Width -}}
|
||||||
|
{{- $Height = $thumbnail.Height -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
<img src="{{ $Permalink }}"
|
||||||
|
{{ with $Srcset }}srcset="{{ . }}"{{ end }}
|
||||||
|
width="{{ $Width }}"
|
||||||
|
height="{{ $Height }}"
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
alt="Featured image of post {{ .Title }}" />
|
alt="Featured image of post {{ .Title }}" />
|
||||||
{{- else -}}
|
{{ else }}
|
||||||
<img src="{{ $image.resource.RelPermalink }}"
|
<img src="{{ $image.permalink }}" loading="lazy" alt="Featured image of post {{ .Title }}" />
|
||||||
width="{{ $image.resource.Width }}"
|
{{ end }}
|
||||||
height="{{ $image.resource.Height }}"
|
</a>
|
||||||
loading="lazy"
|
|
||||||
alt="Featured image of post {{ .Title }}" />
|
|
||||||
{{- end -}}
|
|
||||||
{{ else }}
|
|
||||||
<img src="{{ $image.permalink }}" loading="lazy" alt="Featured image of post {{ .Title }}" />
|
|
||||||
{{ end }}
|
|
||||||
</div>
|
</div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user