Take article_url into account for articles, translated articles, and pages#41
Take article_url into account for articles, translated articles, and pages#41gregsadetsky wants to merge 2 commits into
article_url into account for articles, translated articles, and pages#41Conversation
article_url into account for articles, translated articles, and pages
justinmayer
left a comment
There was a problem hiding this comment.
Hey Greg! Many thanks for your contribution, which seems well-considered and thorough — and even replete with test coverage. Bravo! Much appreciated. 🌟
As I mentioned in the first segment of a recent episode of the Abstractions podcast, I prefer to reserve project-level .gitignore changes for project-specific entries, with more general entries (such as __pycache__/) going into the global ~/.gitignore file on developers’ individual workstations. Also, even if these kinds of changes were welcomed, they would be best submitted in the context of a separate commit and pull request. So I have removed that change and have merged your other changes manually.
Finally, in the future I suggest creating a new feature branch instead of making your changes in your fork’s main branch. This will make things a bit easier for maintainers if and when they need to make changes directly in the context of your pull request.
Thanks for listening to these very minor suggestions for the future. Once again, thank you very much for your work on this!
|
@kernc: Many thanks for reviewing. Very helpful. Much obliged! |
|
These changes were released in Sitemap plugin version 1.2.2 ✨ |
|
amazing, thanks a lot for the review, the merge and the new version release! thanks for the note re: feature branch (my bad) and the happy to also confirm that my blog (which uses pelican & this plugin) is now back to not having 404s in its sitemap :-) which was the goal all along :-) cheers! |
Fixes #32.
the plugin was using the filesystem path to generate urls instead of respecting the
ARTICLE_URLandPAGE_URLsettings. so if you hadARTICLE_URLset to"blog/{slug}/"butARTICLE_SAVE_ASas"{slug}/index.html", the sitemap would showexample.com/test-post/when it should showexample.com/blog/test-post/. same issue for pages with customPAGE_URLsettings.instead of deriving the url from the filesystem path using
to_url(path), we just useobj.urldirectly for articles and pages since Pelican already computed the correct url respecting the defined settings. for index pages like archives and tags we still useto_url(path)since the related objects don't have a url property.also fixed the same issue in translation alternate links. those were using
trans.save_aswhen they should usetrans.urlfor the same reason.added tests to cover the custom
ARTICLE_URLscenario, customPAGE_URLscenario, and translation links with custom urls. these two latter code paths did not have test coverage before.all existing tests still pass and linting is clean.
cheers!