You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

25 lines
665 B

<!-- 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 }}