Inline docs: Update Blogging section to use "sort_by" filter
This commit is contained in:
parent
be46e19677
commit
24b58175a4
@ -117,7 +117,7 @@ something like the following:
|
|||||||
This template will show a list of your articles, so you probably want to
|
This template will show a list of your articles, so you probably want to
|
||||||
do something like this:
|
do something like this:
|
||||||
```
|
```
|
||||||
{% for page in pages %}
|
{% for page in pages|sort_by("time")|reverse %}
|
||||||
{% if page.id starts with "blog/" %}
|
{% if page.id starts with "blog/" %}
|
||||||
<div class="post">
|
<div class="post">
|
||||||
<h3><a href="{{ page.url }}">{{ page.title }}</a></h3>
|
<h3><a href="{{ page.url }}">{{ page.title }}</a></h3>
|
||||||
@ -127,16 +127,10 @@ something like the following:
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
```
|
```
|
||||||
4. Let Pico sort pages by date by setting `$config['pages_order_by'] = 'date';`
|
4. Make sure to exclude the blog articles from your page navigation. You can
|
||||||
in your `config/config.php`. To use a descending order (newest articles
|
|
||||||
first), also add `$config['pages_order'] = 'desc';`. The former won't affect
|
|
||||||
pages without a `Date` meta header, but the latter does. To use ascending
|
|
||||||
order for your page navigation again, add Twigs `reverse` filter to the
|
|
||||||
navigation loop (`{% for page in pages|reverse %}...{% endfor %}`) in your
|
|
||||||
themes `index.twig`.
|
|
||||||
5. Make sure to exclude the blog articles from your page navigation. You can
|
|
||||||
achieve this by adding `{% if not page starts with "blog/" %}...{% endif %}`
|
achieve this by adding `{% if not page starts with "blog/" %}...{% endif %}`
|
||||||
to the navigation loop.
|
to the navigation loop (`{% for page in pages|reverse %}...{% endfor %}`)
|
||||||
|
in your themes `index.twig`.
|
||||||
|
|
||||||
## Customization
|
## Customization
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user