Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix erroring suggestion in docs #2087

Merged
merged 1 commit into from
Feb 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions docs/content/documentation/templates/archive.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,16 @@ all post titles ordered by year). However, this can be accomplished directly in
```

This snippet assumes that posts are sorted by date and that you want to display the archive
in descending order. If you want to show articles in ascending order, add a `reverse` filter
after `group_by`.
in descending order. If you want to show articles in ascending order, you need to further
process the list of pages:
```jinja2
{% set posts_by_year = section.pages | group_by(attribute="year") %}
{% set_global years = [] %}
{% for year, ignored in posts_by_year %}
{% set_global years = years | concat(with=year) %}
{% endfor %}
{% for year in years | reverse %}
{% set posts = posts_by_year[year] %}
{# (same as the previous snippet) #}
{% endfor %}
```