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

Provide an option flag to allow opening source links in a new tab #2415

Closed
JamesLMilner opened this issue Oct 20, 2023 · 2 comments
Closed
Labels
enhancement Improved functionality

Comments

@JamesLMilner
Copy link

Search Terms

CSP, new tab, tab links, GitHub pages

Problem

At the moment all links to source code do not open in new tabs by default. There is no issue in this behaviour as it is expected, however if you are hosting your docs in an iframe in a page that has the CSP policy frame ancestors: none then the page will fail to load in the iframe. Sites such as GitHub Pages have this policy enabled, making it hard to host the docs on GitHub pages.

Suggested Solution

It would be great if there was a flag to enable adding target="_blank" which opens the link in a new tab. Perhaps something like sourceLinkNewTab which defaults to true but is configurable to false.

This would result in the generated HTML going from something like this:

<li>Defined in <a href="https://github.com/JamesLMilner/terra-draw/blob/f640815/src/terra-draw.ts#L69">terra-draw.ts:69</a></li>

to this:

<li>Defined in <a href="https://github.com/JamesLMilner/terra-draw/blob/f640815/src/terra-draw.ts#L69" target="_blank" rel="noopener noreferrer">terra-draw.ts:69</a></li>

I feel like people hosting there docs on GitHub Pages is probably a common use case so this feels like it would be beneficial to others hopefully.

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Oct 20, 2023

GitHub Pages is probably a common use case

Certainly! This is the first time I've heard of someone using an iframe though... shudder

I actually thought these links already opened in a new tab, I meant to do that for all external links...

@JamesLMilner
Copy link
Author

Thanks for this! Really helpful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improved functionality
Projects
None yet
Development

No branches or pull requests

2 participants