Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes to "staying on the same page functionality" (version with tests removed) #7559

Merged
merged 4 commits into from
Sep 27, 2024

Conversation

ilyagr
Copy link
Contributor

@ilyagr ilyagr commented Sep 24, 2024

This is #7350 with the tests removed, as requested in
#7350 (comment) .

I do urge you to reconsider and merge something like #7350 (including
the tests I wrote) instead. Without tests, I suspect this code will
break like its previous version did
. Once the code does break, it might be difficult to fix without tests.

Even if other parts of the theme work without tests, and even if you aren't in love with
how I set up the infrastructure in #7350 or #7338, I think this logic is complex enough
to need tests to be maintainable. Again, I wouldn't be able to check this code's correctness
without the tests that aren't included in this PR. You can always change
the infrastructure to something you like better later.

Of course, this is your project to maintain, so do what works best for you. If
this is the version that's most helpful to you, hope it helps!


Fixes #7226

Additionally, this allows using the version switcher even if the website
is published at a different URL than the site_url. In particular,
the version switcher should now work locally when serving the site with
mike serve.

@squidfunk
Copy link
Owner

Thanks for doing this!

To be clear, I did not say that we do not want tests, it's just the wrong time to start with it right now.

Two things: please change your filenameing convention to how we structured the rest of this repository – find a shorter name and put it into a directory, as the rest of the entire TypeScript codebase, something like corresponding-page/index.md, or shorter. The reason is that it's easier to put files alongside files, like .eslintrc and friends.

Additionally, please add a description to the functions, so that comments are complete, and please fix the remaining checks.

…tching versions"

This commit is a no-op refactor to make reviewing the following commit
easier.
This is squidfunk#7350 with the tests removed, as requested in
squidfunk#7350 (comment) .

I do urge you to reconsider and merge something like squidfunk#7350 (including
the tests I wrote) instead. Without tests, I suspect this code will
break like its [previous version did](
squidfunk@ceacfe5)
. Once the code does break, it might be difficult to fix without tests.

Even if other parts of the theme work without tests, and even if you aren't in love with
how I set up the infrastructure in squidfunk#7350 or squidfunk#7338, I think this logic is complex enough
to need tests to be maintainable. Again, I wouldn't be able to check this code's correctness
without the tests that aren't included in this PR. 

Of course, this is your project to maintain, so do what works best for you. I just hope
this bugfix helps.

---------------------

Fixes squidfunk#7226

Additionally, this allows using the version switcher even if the website
is published at a different URL than the `site_url`. In particular,
the version switcher should now work locally when serving the site with
`mike serve`.
I polyfilled `URL.parse` since many browsers don't support it yet,
apparently.

I'd like this function to never throw an exception, any error should
lead to it simply returning `undefined`.
@ilyagr
Copy link
Contributor Author

ilyagr commented Sep 26, 2024

OK, done.

@squidfunk
Copy link
Owner

Thanks, LGTM!

@squidfunk squidfunk merged commit aeb9492 into squidfunk:master Sep 27, 2024
4 checks passed
ilyagr added a commit to martinvonz/jj that referenced this pull request Sep 29, 2024
This will hopefully make the version switcher stay
on the same page as it includes
squidfunk/mkdocs-material#7559.
Unfortunately, it might break again for reasons explained
there.
ilyagr added a commit to martinvonz/jj that referenced this pull request Sep 29, 2024
This will hopefully make the version switcher stay
on the same page as it includes
squidfunk/mkdocs-material#7559.
Unfortunately, it might break again for reasons explained
there.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Version switcher fails to stay on the same page when canonical_version is set in mike
2 participants