Hello,
Derived my /categories/category_name
permalink, I’d like to use the value of category_name
to affect my where
invocation within the logic of my taxonomy.html
file so that only posts of category_name
show up. Clearly a call for where
.
But I was surprised that there was no way to easily extract category_name
. I would have thought it would have been easier than what’s suggested here. I modified this idea (in a very ugly fashion) and I was wondering whether someone might suggest a more succinct way to do what I’m doing.
{{ $subsection := slice (index (last 1 (split (delimit (split .Permalink "/") "," "") ",") ) 0 | humanize) }}
{{ range where .Pages.ByDate "Params.categories" "intersect" $subsection }}
Thus for /categories/microblog
, $subsection
becomes ["Microblog"]
which can be used to intersect the Pages whose categories
value in their front-matter matches ["Microblog"]
. Is there a place for cleanup here? In Ruby I wouldwrite something like:
Array(x.split('/').last.capitalize)
Is there a way to get closer to that level of concision?