Implement period_archives common context variable#3148
Merged
justinmayer merged 5 commits intoOct 28, 2023
Conversation
Also, set default patterns for time-period *_ARCHIVE_URL settings.
avaris
reviewed
Aug 14, 2023
avaris
reviewed
Aug 14, 2023
So that we don't contribute to further clutter in generate_context.
offbyone
approved these changes
Oct 28, 2023
offbyone
left a comment
Contributor
There was a problem hiding this comment.
This looks good.
Should you add an entry to the changelog for this, or will @justinmayer do that on release?
boxydog
approved these changes
Oct 28, 2023
boxydog
left a comment
Contributor
There was a problem hiding this comment.
I left a few nits, but I don't see anything blocking.
Since I am new to the codebase, I could be missing something.
avaris
approved these changes
Oct 28, 2023
Member
justinmayer
approved these changes
Oct 28, 2023
justinmayer
left a comment
Member
There was a problem hiding this comment.
Many thanks to @djramones for the enhancement and to @boxydog, @offbyone, and @avaris for reviewing. 💯
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
As discussed in #2773 (specifically this comment), a context variable that lists the generated period archives along with their URLs should be useful for those who'd like to have an index to those archives. Before this, users had to manually write links to period archives in content or templates, or even expect site visitors to explore editing URLs on their browser address bar.
Implementation
I moved code from
ArticlesGenerator.generate_period_archives()togenerate_context(). Initially, the new context variable only needed the list ofperiod/period_numtuples and the corresponding URLs, but in order to retain thegenerate_period_archives()functionality, I decided to include the generation ofsave_asand filteredarticles/datescollections.Also, I decided it appropriate to set default patterns for time-period
*_ARCHIVE_URLsettings, so that anyone using the new context var just by setting*_ARCHIVE_SAVE_ASwould get sensible URLs by default too.I thought about providing a default template implementing the new variable (perhaps named
period_archives_index.html), but this is probably more of a website- or theme-level detail, so I just put in a sample HTML snippet in the docs.Pull Request Checklist
Resolves: #2773