May 2023: Changes to Archives #186
kjaymiller
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
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