Jekyll-Models icon indicating copy to clipboard operation
Jekyll-Models copied to clipboard

Enhancement: Linking next / previous model + sorting models

Open sectore opened this issue 12 years ago • 2 comments

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>&nbsp;</li>
    {% endif %}
    {% if page.model.next %}
    <li><a href="{{page.model.next.mdl_url}}">NEXT</a></li>
    {% else %}
    <li>&nbsp;</li>
    {% endif %}
  </ul>
</nav>

sectore avatar Jan 13 '13 10:01 sectore

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.

sectore avatar Jan 23 '13 09:01 sectore

The last two commits (88d401a, f6e3aef) includes the support of latest Jekyll 2.

It would be great if you have a minute to accept the pull requests ;) Thanks!

sectore avatar Jun 01 '14 12:06 sectore