diff options
| author | Mitja Felicijan <mitja.felicijan@gmail.com> | 2024-06-21 17:28:03 +0200 |
|---|---|---|
| committer | Mitja Felicijan <mitja.felicijan@gmail.com> | 2024-06-21 17:28:03 +0200 |
| commit | 0130404a1dc663d4aa68d780c9bcb23a4243e68d (patch) | |
| tree | d57563d101f6bbf08f9bfd6b3214e311d64d4f22 /README.md | |
| parent | 921b7e42fb26e0d9c5b50221eb8c6e5390f51908 (diff) | |
| download | jbmafp-0130404a1dc663d4aa68d780c9bcb23a4243e68d.tar.gz | |
Added additional filters
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 21 |
1 files changed, 18 insertions, 3 deletions
@@ -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 |
