You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Archive is a custom BasePage object designed to show a Collection object's pages.
There used to be logic around how collections were managed.
graph TD;
A[Is there more than one page?]-->B[Yes]
A-->C[No]
B-->D[Archive slug is class name + index of page]
C-->E[Archive slug is class name]
This meant that if you were using pagination the archive for Blog would be blog1.html or blog.html if you weren't.
What if you were using pagination and you only had one page?
That would be blog1.html.
This is fine but caused some issues when #185 began development.
Issue 185
The milestone 2023.5.x was all about creating consistency, documentation, and testing.
There was a challenge to creating consistent behavior with the new url_for filter logic.
Page objects have a url_for() method that will provide the page's relative url.
When creating stability around using url_for as a jinja2 filter to reference any page in the Site's route list, we needed a way to also reference pages in a Collection and the Archive.
Collections didn't have a url_for attribute. Now there are two behaviors. If you reference a Page that is part of a collection. You will need to use the 'collection.page' structure.
{# The about page is a standalone `Page` #}
{{about | url_for}}
{# The about page is in the `Pages` collection. #}
{{'pages.about'| url_for }}
Now if you want to reference the archive for the page you can just use the Collection._reference attribute (which is the slug by default). You can also reference the paginated values with the page parameter on the url_for filter.
{# The about page is in the `Pages` collection. #}
{{'pages.about'| url_for }}
{# The `pages.archive[0]` url #}
{{'pages'| url_for }}
{# The first index of a paginated archive #}
{{'pages'|url_for(page=1)}}
To make this work in a predictable manner, I made the desicion to provide a standard scheme around pagination and naming.
By default the archives attribute for a Collection has been a list by default. Instead of taking an either/or approach we now have adopted a "why not both" strategy.
Now there will always be an unpaginated Archive that is the first object in Collection.archives.
This means that your archive calling in templates should not change as you were always starting at index 1. This is great for url_for but also provides the ability to "Show All Items" easily as well.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
May 2023: Changes Archives
The
Archive
is a customBasePage
object designed to show aCollection
object's pages.There used to be logic around how collections were managed.
This meant that if you were using pagination the archive for
Blog
would beblog1.html
orblog.html
if you weren't.What if you were using pagination and you only had one page?
That would be
blog1.html
.This is fine but caused some issues when #185 began development.
Issue 185
The milestone 2023.5.x was all about creating consistency, documentation, and testing.
There was a challenge to creating consistent behavior with the new
url_for
filter logic.Page
objects have aurl_for()
method that will provide the page's relative url.When creating stability around using
url_for
as a jinja2 filter to reference any page in theSite
's route list, we needed a way to also reference pages in aCollection
and theArchive
.Collections didn't have a
url_for
attribute. Now there are two behaviors. If you reference aPage
that is part of a collection. You will need to use the'collection.page'
structure.Now if you want to reference the archive for the page you can just use the
Collection._reference
attribute (which is the slug by default). You can also reference the paginated values with thepage
parameter on theurl_for
filter.To make this work in a predictable manner, I made the desicion to provide a standard scheme around pagination and naming.
By default the
archives
attribute for aCollection
has been a list by default. Instead of taking an either/or approach we now have adopted a "why not both" strategy.Now there will always be an unpaginated
Archive
that is the first object inCollection.archives
.This means that your archive calling in templates should not change as you were always starting at index
1
. This is great forurl_for
but also provides the ability to "Show All Items" easily as well.Beta Was this translation helpful? Give feedback.
All reactions