Restruction

This commit is contained in:
2022-02-20 20:00:01 +01:00
parent 3491caf100
commit 10d0349955
22 changed files with 281 additions and 102 deletions
+51 -61
View File
@@ -7,73 +7,63 @@
{{ $PageContext := . }}
{{ if .IsHome }}
{{ $PageContext = .Site }}
<div class="flex-container">
{{ range (where $PageContext.RegularPages "Type" "tiles") }}
{{ range where $PageContext.Site.RegularPages "Type" "tiles" }}
{{ $count := partial "func/count_posts.html" ( dict "context" . "term" .Params.CorrespondingTagName ) }}
<div class="flex-item-left">
{{ partial "tiles-cover.html" . }}
<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 }}
{{ if gt $count 0 }}
<figcaption class="transparentbackgroud post-meta">
<a href="tags/{{ .Params.CorrespondingTagName }}">
#{{ .Params.CorrespondingTagName | plainify }} <small>({{ $count }})</small> </a>
</figcaption >
{{ end }}
</figure>
</div>
{{ end }}
{{ end }}
</div>
<div>
{{ range $.Site.Taxonomies.tags.ByCount }}
{{ $tag_name := .Name }}
{{ $has_tile := "false" }}
{{ range where $.Site.RegularPages "Type" "tiles" }}
{{ if eq .Params.correspondingTagName $tag_name }}
{{ $has_tile = "true" }}
{{ end }}
{{ end }}
{{ if eq $has_tile "false" }}
<span class=" post-meta">
<a href="/tags/{{ .Name }}"> #{{ .Name }} <small>({{ .Count }})</small></a>
</span>
<span>&nbsp;</span>
{{end}}
{{end}}
</div>
{{ end }}
<div class="posts">
{{ $isntDefault := not (or (eq (trim $.Site.Params.contentTypeName " ") "posts") (eq (trim $.Site.Params.contentTypeName " ") "")) }}
{{ $contentTypeName := cond $isntDefault (string $.Site.Params.contentTypeName) "posts" }}
{{ $PageContext := . }}
{{ if .IsHome }}
{{ $PageContext = .Site }}
{{ end }}
{{ $paginator := .Paginate (where $PageContext.RegularPages "Type" $contentTypeName) }}
{{ range $paginator.Pages }}
<div class="post on-list">
<h1 class="post-title">
<a href="{{ .Permalink }}">{{ .Title | markdownify }}</a>
</h1>
<div class="post-meta">
<span class="post-date">
{{ .Date.Format "2006-01-02" }}
</span>
{{ with .Params.Author }}
<span class="post-author">:: {{ . }}</span>
{{ end }}
</div>
{{ if .Params.tags }}
<span class="post-tags">
{{ range .Params.tags }}
#<a href="{{ (urlize (printf "tags/%s/" . )) | absLangURL }}">
{{- . -}}
</a>&nbsp;
{{ end }}
</span>
{{ end }}
{{ partial "cover.html" . }}
<div class="post-content">
{{ if .Params.showFullContent }}
{{ .Content }}
{{ else if .Description }}
{{ .Description | markdownify }}
{{ else }}
{{ .Summary | markdownify }}
{{ end }}
</div>
{{ if not .Params.showFullContent }}
<div>
<a class="read-more button"
href="{{.RelPermalink}}">{{ $.Site.Params.ReadMore }} →</a>
</div>
{{ end }}
</div>
{{ end }}
{{ partial "pagination.html" . }}
</div>
{{ end }}
+25
View File
@@ -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 }}
+29
View File
@@ -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 }}
+29 -23
View File
@@ -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 }}
+70
View File
@@ -0,0 +1,70 @@
{{ define "main" }}
<div class="post">
<div class="post-meta">
<div class="post-content">
{{ if .Description }}
{{ .Description | markdownify }}
{{ end }}
<h1 class="post-subtitle">{{ .Title | markdownify }}</h1>
</div>
</div>
{{ if .Params.tags }}
<span class="post-tags">
{{ range .Params.tags }}
#<a href="{{ (urlize (printf "tags/%s/" .)) | absLangURL }}">{{ . }}</a>&nbsp;
{{ end }}
</span>
{{ end }}
{{ partial "tag-cover.html" . }}
<div class="posts">
{{ $isntDefault := not (or (eq (trim $.Site.Params.contentTypeName " ") "posts") (eq (trim $.Site.Params.contentTypeName " ") "")) }}
{{ $contentTypeName := cond $isntDefault (string $.Site.Params.contentTypeName) "posts" }}
{{ $PageContext := . }}
{{ if .IsHome }}
{{ $PageContext = .Site }}
{{ end }}
{{ $paginator := .Paginate (where $PageContext.RegularPages "Type" $contentTypeName) }}
{{ range $paginator.Pages }}
<div class="post on-list">
<h1 class="post-title">
<a href="{{ .Permalink }}">{{ .Title | markdownify }}</a>
</h1>
<div class="post-meta">
<span class="post-date">
{{ .Date.Format "2006-01-02" }}
</span>
{{ with .Params.Author }}
<span class="post-author">:: {{ . }}</span>
{{ end }}
</div>
{{ partial "cover.html" . }}
<div class="post-content">
{{ if .Params.showFullContent }}
{{ .Content }}
{{ else if .Description }}
{{ .Description | markdownify }}
{{ else }}
{{ .Summary | markdownify }}
{{ end }}
</div>
{{ if not .Params.showFullContent }}
<div>
<a class="read-more button"
href="{{.RelPermalink}}">{{ $.Site.Params.ReadMore }} →</a>
</div>
{{ end }}
</div>
{{ end }}
{{ partial "pagination.html" . }}
</div>
{{ end }}