How to make an ascending list with Jekyll and Liquid?

I'm starting with Liquid and Jekyll can someone help me with a list in ascending order (by {{category}} name)?

<div class="col-xs-6 col-sm-3 patickaborder">
                <h5>Rubriky</h5>
                    <ul>
                        {% for category in site.categories order:ascending %}
                            <li><a href="{{ site.url }}{{ category | first }}/index.html">{{ category | first }}</a></li>
                        {% endfor %}
                    </ul>
            </div>
+4
source share
2 answers

As far as I know, there is no built-in way for ordering at the moment, this is only possible with plugins.

The syntax order:ascendingyou use in your question will probably work in the future when it is implemented in Liquid .
There is another answer in the same question that shows how to sort with the plugin (which means that it will not work on GitHub pages!) .


, ... - Liquid-foo.

, site.tags , .

+1

. , , :

{% assign sortedcats = site.categories | sort %}

<div class="col-xs-6 col-sm-3 patickaborder">
    <h5>Rubriky</h5>
        <ul>
            {% for category in sortedcats %}
                <li><a href="{{ site.url }}{{ category | first }}/index.html">{{ category | first }}</a></li>
            {% endfor %}
        </ul>
</div>
+11

Source: https://habr.com/ru/post/1531762/


All Articles