Got nested columns in your grid-based Jekyll site?
Wondered why you didn't have a way to calculate the modulo inside your posts loop to open and close your 'rows' containing those nested columns?
Add this filter to your _plugins
directory, and use it like so:
{{ x | mod:y }}
Note: Liquid will return this as a string, so be aware of that when using comparisons.
What about an actual example for nesting those columns?
{% for post in site.posts %}
{% capture modulo %}{{ forloop.index0 | mod:3 }}{% endcapture %}
{% if modulo == '0' or forloop.first %}
<div class="row">
{% endif %}
<!-- don't forget those pesky 'alpha' and 'omega' tags if they're in there -->
<div class="three-columns {{ cycle 'alpha', '', 'omega' }}">
... POST STUFF ...
</div>
{% if modulo == '2' or forloop.last %}
</div>
{% endif %}
{% endfor %}
Adapt to suit the specific framework. For something like Skeleton, you might prefer one-third column
.
Thanks alot man very helpful