summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorMitja Felicijan <mitja.felicijan@gmail.com>2024-06-21 17:28:03 +0200
committerMitja Felicijan <mitja.felicijan@gmail.com>2024-06-21 17:28:03 +0200
commit0130404a1dc663d4aa68d780c9bcb23a4243e68d (patch)
treed57563d101f6bbf08f9bfd6b3214e311d64d4f22 /README.md
parent921b7e42fb26e0d9c5b50221eb8c6e5390f51908 (diff)
downloadjbmafp-0130404a1dc663d4aa68d780c9bcb23a4243e68d.tar.gz
Added additional filters
Diffstat (limited to 'README.md')
-rw-r--r--README.md21
1 files changed, 18 insertions, 3 deletions
diff --git a/README.md b/README.md
index df1417d..e2dbd71 100644
--- a/README.md
+++ b/README.md
@@ -163,28 +163,43 @@ Payload {
- first (gets first N posts)
- last (gets last N posts)
- random (gets random N posts)
+- filterbytype (get just the posts with specific type)
```html
<!-- First 10 pages -->
-{{ range first 10 .Pages }}
+{{ range .Pages | first 10 }}
{{ if and (eq .Type "post") (not .Draft) }}
<li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
{{ end }}
{{ end }}
<!-- Last 10 pages -->
-{{ range last 10 .Pages }}
+{{ range .Pages | last 10 }}
{{ if and (eq .Type "post") (not .Draft) }}
<li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
{{ end }}
{{ end }}
<!-- Random 10 pages -->
-{{ range random 10 .Pages }}
+{{ range .Pages | random 10 }}
{{ if and (eq .Type "post") (not .Draft) }}
<li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
{{ end }}
{{ end }}
+
+<!-- Filter by type -->
+{{ range .Pages | filterbytype "post" }}
+ {{ if not .Draft }}
+ <li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
+ {{ end }}
+{{ end }}
+
+<!-- Chain multiple together -->
+{{ range .Pages | filterbytype "post" | random 20 | first 5 }}
+ {{ if not .Draft }}
+ <li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
+ {{ end }}
+{{ end }}
```
## Additional material