Closed squidfunk closed 1 year ago
I'm not sure whether the failing tests are false positives or not, due to the changed input of the function.
The fact that the tests only check get_relative_html_path
made them fail, as this function now receives URL inputs (previously .md
inputs). For this reasons, we now create the File
objects that MkDocs will create, and pass them to the function. I guess there are several opportunities for refactoring since the logic should be much simpler now, but I'm not confident enough to do the refactoring as I just touched the code base for the first time.
Any thoughts on why Python 2.7 fails?
This is a great implementation! I am able to reproduce locally with Python 2.7, looking into it. Also I suspect we will be able to throw away a bit more code after this.
Uuh Python 2.7 fails because it's forced to install MkDocs 1.0.4 and that was prior to this very old bugfix...
And these failures are real with MkDocs 1.0.4 :grimacing:
Yeah, I'm not sure how to proceed here. Is Python 2.7 support still necessary? I'm not familiar enough with the ecosystem to judge. Could we issue a new release without Python 2.7 support, locking it into using the version before the merge?
I think I'll drop it. And I'm also working on some change to tests so I can be more confident in them
So I indeed dropped Python 2.7.
We're fine to merge this as is, just with the changes I suggested.
Afterwards I'll apply my refactoring of tests: https://github.com/mkdocs/mkdocs-redirects/compare/bb2ee628e2c064bd7ebc7d72e4426fa114ae7e1a With these tests I am already very confident that this is good.
All good, thanks for looking at this!
Fixes #46
When defining redirects for Material for MkDocs' new built-in blog plugin, I stumbled upon a problem where computed URLs are not taken into account. The blog plugin recursively enumerates all Markdown files in the folder
docs/blog/posts
and then rewrites theFile
objects to have the correctdest_path
andurl
values in theon_files
hook. This is done so MkDocs and other plugins know the correct destinations for all blog posts. The result looks like this:Now, when I map the old paths to the new
src_path
, the redirects plugin will ignore the computed,file.url
and compute the target URL by itself, resulting inblog/posts/blog-support-just-landed/
, which mismatches the destination URL.This PR fixes the problem by using the computed URL, so the following configuration is correct: