postlist-for-micro.blog/layouts/shortcodes/postlist.html

81 lines
2.8 KiB
HTML
Raw Normal View History

{{- $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")) "" -}}
2025-06-25 11:23:29 +00:00
{{- $pgr := where .Site.RegularPages "Section" "ne" "" -}}
{{- $pgr = where $pgr "Section" "not in" (slice "replies") -}}
{{- if (ne $parCategories "") -}}
{{- range (split $parCategories ",") -}}
2025-06-25 11:23:29 +00:00
{{- $pgr = (where $pgr "Params.categories" "intersect" (slice .)) -}}
{{- end -}}
{{- end -}}
{{- if (ne $parTitleMatches "") -}}
{{- $pgr = (where $pgr "Params.title" "like" $parTitleMatches) -}}
2025-08-15 23:54:29 +00:00
{{- end -}}
2025-07-02 11:04:52 +00:00
{{- if (ne $parOrder "") -}}
{{- $order := split $parOrder " " -}}
2025-07-02 11:04:52 +00:00
{{- if (eq (index $order 0) "alpha" ) -}}
{{- $pgr = $pgr.ByTitle -}}
2025-07-02 11:04:52 +00:00
{{- 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 -}}
2025-06-25 11:23:29 +00:00
{{- end -}}
2025-07-02 11:04:52 +00:00
{{- if (ne $parLimit "") -}}
{{- $pgr = $pgr.Limit (int $parLimit) -}}
2025-07-05 23:37:09 +00:00
{{- end -}}
{{- if (eq $parDisplay "content") -}}
{{ if templates.Exists "partials/_postlist/post-content-before.html" }}
2025-07-06 00:20:35 +00:00
{{ partial "_postlist/post-content-before.html" $pgr }}
{{ end }}
2025-07-05 23:37:09 +00:00
<div class="postlist postlist-display-content h-feed">
{{ range $pgr }}
2025-07-06 00:20:35 +00:00
{{ if templates.Exists "partials/_postlist/post-content.html" }}
2025-07-06 00:23:06 +00:00
{{ partial "_postlist/post-content.html" . }}
2025-07-06 00:20:35 +00:00
{{ 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 }}
2025-07-05 23:37:09 +00:00
{{ end }}
</div>
{{ if templates.Exists "partials/_postlist/post-content-after.html" }}
2025-07-06 00:20:35 +00:00
{{ partial "_postlist/post-content-after.html" $pgr }}
{{ end }}
2025-06-25 11:23:29 +00:00
{{- else -}}
2025-07-05 23:37:09 +00:00
<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>
2025-07-05 23:39:08 +00:00
{{- else -}}
2025-07-05 23:37:09 +00:00
<li><a href="{{ .RelPermalink }}">{{ .Content | safeHTML | truncate 70 }}</a></li>
{{ end }}
{{ end }}
</ul>
{{- end -}}