pydata-sphinx-theme
pydata-sphinx-theme copied to clipboard
Replace external links to GitHub and GitLab with shortened links
Context
Many projects have links back to their issues / PRs hosted on platforms like GitHub or GitLab. Instead of displaying these as raw links, it might be nice if we instead did some lightweight formatting for these platforms specifically, to mimic how GitHub shortens its own internal links.
For example, here's a similar link shortening that we use on our github website. This happens if we use a "raw" external github link, like this:
Here's my text and a link: https://github.com/2i2c-org/infrastructure/issues/1329

Implementation
I think this wouldn't be too hard to implement, basically we'd need to add an event listener for when the page doctree is parsed, and then:
- Loop through each link
- For any links that have a body that is just an external link (e.g.
https://etc), then: - If it begins with
https://github.com, replace it with the appropriate shortened text however we like.