when using a url: entry in the TOC: how to open it in a separate tab/window #1173
-
I just came across the ability to add entries of the form url: to other URLs right in the TOC this is very useful ! is there currently a way to tweak that ? I was thinking maybe something like
inspired from the I could not find that in the doc (not sure if the above mentioned section is the only place where this is mentioned, or if I should look for a more 'reference-oriented' section some place else...) if that's not yet possible, how does that sound ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The answer right now is that you can use custom JS to set the target on these pages: document.querySelectorAll("nav a.reference.external").forEach(node => {node.target = "_blank"}) Then you can load this JS on each page: https://pydata-sphinx-theme.readthedocs.io/en/latest/user_guide/static_assets.html#define-a-list-of-assets-in-conf-py For JupyterBook, you would set this in your For MyST-MD, we don't yet support external URLs in the main table of contents, though it is something that we're thinking about: jupyter-book/mystmd#1188 |
Beta Was this translation helpful? Give feedback.
The answer right now is that you can use custom JS to set the target on these pages:
Then you can load this JS on each page: https://pydata-sphinx-theme.readthedocs.io/en/latest/user_guide/static_assets.html#define-a-list-of-assets-in-conf-py
For JupyterBook, you would set this in your
_config.yml
e.g. https://jupyterbook.org/en/stable/advanced/html.html#use-plausible-analytics.For MyST-MD, we don't yet support external URLs in the main table of contents, though it is something that we're thinking about: jupyter-book/mystmd#1188