Inline docs: Update Blogging section to use "sort_by" filter
This commit is contained in:
parent
be46e19677
commit
24b58175a4
1 changed files with 4 additions and 10 deletions
|
@ -117,7 +117,7 @@ something like the following:
|
|||
This template will show a list of your articles, so you probably want to
|
||||
do something like this:
|
||||
```
|
||||
{% for page in pages %}
|
||||
{% for page in pages|sort_by("time")|reverse %}
|
||||
{% if page.id starts with "blog/" %}
|
||||
<div class="post">
|
||||
<h3><a href="{{ page.url }}">{{ page.title }}</a></h3>
|
||||
|
@ -127,16 +127,10 @@ something like the following:
|
|||
{% endif %}
|
||||
{% endfor %}
|
||||
```
|
||||
4. Let Pico sort pages by date by setting `$config['pages_order_by'] = 'date';`
|
||||
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
|
||||
4. Make sure to exclude the blog articles from your page navigation. You can
|
||||
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
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue