Hi all. I have an element to show featured content with certain categories so here is my code
achetypes
featured: "true"
categories:
- photography
template
{{ range first 1 (where .Data.Pages "Type" "blog") }}
{{ if and (in .Params.categories "photography") (isset .Params "featured") }}
bla bla bla...
{{ end }}
{{ end }}
The code have no error but the problem is the true or false statement on the archetypes have no affect at all.
Kindly show me whats wrong with my conditional code.
by the way I’m using different approach like below
{{ range (where .Data.Pages "Type" "blog") 1 }}
{{ if and (in .Params.categories "photography") (in .Params.featured "true") }}
// MYCODE...
{{ end }}
{{ end }}
the code working, but Hugo render more than 1 post.
I try the alternative
{{ range first 1 (where .Data.Pages "Type" "blog") }}
the result is nothing rendered.
{{ $photography := .Data.Pages.ByParam "categories" }}
{{ if and (in .Params.featured "true") (eq .Params.categories "photography") }}
{{ range first 1 $photography }}
the code have no error but it doesnt render at all (blank)
I’m not sure about this but finaly solved using this code
{{range $chap,$tax := .Site.Taxonomies.categories }}
{{ range first 1 $tax.Pages.ByDate.Reverse }}
{{ if and (in .Params.categories "photography") (in .Params.featured "true") }}