Jekyll-Models
Jekyll-Models copied to clipboard
Enhancement: Linking next / previous model + sorting models
To link from one model to another within a template ("pagination") it might be helpful to have linked models using model.next and model.previous.
Example:
<nav>
<ul>
{% if page.model.previous %}
<li><a href="{{page.model.previous.mdl_url}}">PREVIOUS</a></li>
{% else %}
<li> </li>
{% endif %}
{% if page.model.next %}
<li><a href="{{page.model.next.mdl_url}}">NEXT</a></li>
{% else %}
<li> </li>
{% endif %}
</ul>
</nav>
The second commit includes an option to sort models by a key. The key and the sort direction are defined in _config.yml.
jekyll_models_sort_by: timestamp
jekyll_models_sort_descending: true
Both parameters are optional. If no value is set, models will be sorted by using its YAML file names (as before)
The sorting option is necessary to use previous commit for linking models in a right order.