mirror of
https://github.com/lmika/postlist-for-micro.blog.git
synced 2025-08-25 16:36:09 +00:00
- Fixed issue with postlist not showing anything where called without parameters - Switch alpha sort to ByTitle
81 lines
2.8 KiB
HTML
81 lines
2.8 KiB
HTML
{{- $parCategories := or (and .Params (.Get "categories")) "" -}}
|
|
{{- $parTitleMatches := or (and .Params (.Get "title-matches")) "" -}}
|
|
{{- $parOrder := or (and .Params (.Get "order")) "" -}}
|
|
{{- $parLimit := or (and .Params (.Get "limit")) "" -}}
|
|
{{- $parDisplay := or (and .Params (.Get "display")) "" -}}
|
|
|
|
{{- $pgr := where .Site.RegularPages "Section" "ne" "" -}}
|
|
{{- $pgr = where $pgr "Section" "not in" (slice "replies") -}}
|
|
|
|
{{- if (ne $parCategories "") -}}
|
|
{{- range (split $parCategories ",") -}}
|
|
{{- $pgr = (where $pgr "Params.categories" "intersect" (slice .)) -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{- if (ne $parTitleMatches "") -}}
|
|
{{- $pgr = (where $pgr "Params.title" "like" $parTitleMatches) -}}
|
|
{{- end -}}
|
|
|
|
{{- if (ne $parOrder "") -}}
|
|
{{- $order := split $parOrder " " -}}
|
|
{{- if (eq (index $order 0) "alpha" ) -}}
|
|
{{- $pgr = $pgr.ByTitle -}}
|
|
{{- else if (eq (index $order 0) "date" ) -}}
|
|
{{- $pgr = $pgr.ByDate -}}
|
|
{{- end -}}
|
|
{{- if (and (eq (len $order) 2) (eq (index $order 1) "desc")) -}}
|
|
{{- $pgr = $pgr.Reverse -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{- if (ne $parLimit "") -}}
|
|
{{- $pgr = $pgr.Limit (int $parLimit) -}}
|
|
{{- end -}}
|
|
|
|
{{- if (eq $parDisplay "content") -}}
|
|
{{ if templates.Exists "partials/_postlist/post-content-before.html" }}
|
|
{{ partial "_postlist/post-content-before.html" $pgr }}
|
|
{{ end }}
|
|
<div class="postlist postlist-display-content h-feed">
|
|
{{ range $pgr }}
|
|
{{ if templates.Exists "partials/_postlist/post-content.html" }}
|
|
{{ partial "_postlist/post-content.html" . }}
|
|
{{ else }}
|
|
<div class="h-entry">
|
|
{{ if .Title }}
|
|
<h2 class="p-name"><a href="{{ .Permalink }}">{{ .Title }}</a></h2>
|
|
{{ if .Params.custom_summary }}
|
|
<div class="p-summary">
|
|
<p>{{ .Summary | safeHTML }}<p>
|
|
</div>
|
|
{{ else }}
|
|
<div class="e-content">
|
|
{{ .Content }}
|
|
</div>
|
|
{{ end }}
|
|
{{ else }}
|
|
<div class="e-content">
|
|
{{ .Content }}
|
|
</div>
|
|
{{ end }}
|
|
</div>
|
|
{{ end }}
|
|
{{ end }}
|
|
</div>
|
|
{{ if templates.Exists "partials/_postlist/post-content-after.html" }}
|
|
{{ partial "_postlist/post-content-after.html" $pgr }}
|
|
{{ end }}
|
|
{{- else -}}
|
|
<ul class="postlist">
|
|
{{ range $pgr }}
|
|
{{- if (ne .LinkTitle "") -}}
|
|
<li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
|
|
{{- else if (ne .Summary "") -}}
|
|
<li><a href="{{ .RelPermalink }}">{{ .Summary | safeHTML | truncate 70 }}</a></li>
|
|
{{- else -}}
|
|
<li><a href="{{ .RelPermalink }}">{{ .Content | safeHTML | truncate 70 }}</a></li>
|
|
{{ end }}
|
|
{{ end }}
|
|
</ul>
|
|
{{- end -}} |