Restruction
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
|
||||
<!-- Function to count number of posts for a given tag name -->
|
||||
<!-- Example: Count posts with tag="ddo" -->
|
||||
<!-- len={ { partial "count_posts.html" ( dict "context" $PageContext "term" "ddo" ) } } -->
|
||||
{{$term := .term}}
|
||||
{{$taxo := "tags"}}
|
||||
{{ $ret := -1 }}
|
||||
|
||||
|
||||
<!-- Get all posts-->
|
||||
{{ $posts := where .context.Site.Pages "Type" "posts" }}
|
||||
|
||||
{{ $data := newScratch }}
|
||||
|
||||
<!-- (re)set the counter to 0 -->
|
||||
{{ $data.Set "tagCounter" 0 }}
|
||||
<!-- increment counter if post contains the current tag-->
|
||||
{{ range $posts}}
|
||||
{{ if in .Params.tags $term }}
|
||||
{{ $data.Add "tagCounter" 1 }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ $ret = $data.Get "tagCounter" }}
|
||||
|
||||
{{ return $ret }}
|
||||
@@ -0,0 +1,29 @@
|
||||
{{- $cover := false -}}
|
||||
{{- $autoCover := default $.Site.Params.autoCover false }}
|
||||
{{- if index .Params "cover" -}}
|
||||
{{- if .Resources.GetMatch .Params.Cover }}
|
||||
{{- $cover = (.Resources.GetMatch .Params.Cover).RelPermalink -}}
|
||||
{{- else -}}
|
||||
{{- $cover = absURL .Params.Cover -}}
|
||||
{{- end -}}
|
||||
{{- else if $.Site.Params.AutoCover -}}
|
||||
{{- if (not .Params.Cover) -}}
|
||||
{{- if .Resources.GetMatch "cover.*" -}}
|
||||
{{- $cover = (.Resources.GetMatch "cover.*").RelPermalink -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{ if .Params.urlLink }}
|
||||
{{if $cover -}}
|
||||
<!-- Cover image found -->
|
||||
<div>
|
||||
<a href="https://{{ .Params.urlLink }}" class="nodeco x post-meta">
|
||||
<img src="{{ $cover }}" class="headerimage"
|
||||
alt="{{ .Title | plainify | default " " }}"
|
||||
title="{{ .Params.urlLink |plainify|default "Cover Image" }}" />
|
||||
{{ .Params.urlLink }}
|
||||
</a>
|
||||
</div>
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
@@ -1,25 +1,31 @@
|
||||
{{- $cover := false -}}
|
||||
{{- $autoCover := default $.Site.Params.autoCover false }}
|
||||
{{ range where .Site.RegularPages "Type" "tiles" }}
|
||||
|
||||
{{- if index .Params "cover" -}}
|
||||
{{- if .Resources.GetMatch .Params.Cover }}
|
||||
{{- $cover = (.Resources.GetMatch .Params.Cover).RelPermalink -}}
|
||||
{{- else -}}
|
||||
{{- $cover = absURL .Params.Cover -}}
|
||||
{{- end -}}
|
||||
{{- else if $.Site.Params.AutoCover -}}
|
||||
{{- if (not .Params.Cover) -}}
|
||||
{{- if .Resources.GetMatch "cover.*" -}}
|
||||
{{- $cover = (.Resources.GetMatch "cover.*").RelPermalink -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{ $count := partial "func/count_posts.html" ( dict "context" . "term" .Params.CorrespondingTagName ) }}
|
||||
|
||||
{{if $cover -}}
|
||||
<!-- Cover image found -->
|
||||
<a href="https://{{ .Params.urlLink }}">
|
||||
<img src="{{ $cover }}"
|
||||
alt="{{ .Title | plainify | default " " }}"
|
||||
title="{{ .Params.CoverCredit |plainify|default "Cover Image" }}" />
|
||||
</a>
|
||||
{{- end }}
|
||||
<figure >
|
||||
|
||||
{{if .Params.Cover }}
|
||||
<!-- Cover image found -- found in tiles -->
|
||||
<a href="https://{{ .Params.urlLink }}">
|
||||
<img src="{{ .Params.Cover }}"
|
||||
alt="{{ .Title | plainify | default " " }}"
|
||||
title="{{ .Params.CoverCredit |plainify|default "Cover Image" }}" /></a>
|
||||
|
||||
{{ else }}
|
||||
|
||||
<!-- No cover image found -->
|
||||
<a href="https://{{ .Params.urlLink }}">
|
||||
{{ .Title | plainify | default " " }} </a>
|
||||
|
||||
{{ end }}
|
||||
|
||||
<figcaption >
|
||||
{{ if gt $count 0 }}
|
||||
<a href="tags/{{ .Params.CorrespondingTagName }}">
|
||||
#{{ .Params.CorrespondingTagName | plainify }} <small>({{ $count }})</small> </a>
|
||||
{{ end }}
|
||||
</figcaption >
|
||||
|
||||
</figure>
|
||||
|
||||
{{ end }}
|
||||
Reference in New Issue
Block a user