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

Added open-external-links.js to open external links in new tab #7540

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

rahulmansharamani14
Copy link

Summary

This PR ensures that all external links in the Mattermost documentation open in a new tab or window, addressing Issue #7048.

Changes Made

  • Added open-external-links.js:

    • Located in the _static/js directory.
    • Contains JavaScript code that adds target="_blank" to all external links.
  • Updated conf.py:

    • Added open-external-links.js in the html_js_files list to include this file in the build process.

Implementation Details

  • The script selects all <a> elements and checks if they have the external class.
  • External links are modified to include target="_blank", opening them in a new tab/window.

Testing

  • Built the documentation locally using make clean build.
  • Verified that:
    • External links open in a new tab/window.
    • Internal links open in the same tab/window.
  • Tested across multiple pages.

Notes

  • This solution depends on external links being assigned the external class by Sphinx during the build process.
  • No additional dependencies are introduced.
  • No changes to existing content or functionality other than modifying external link behavior.

Thank you for reviewing my PR. I'm open to any feedback or suggestions.

Ticket Link

Fixes #7048

@mattermost-build
Copy link
Contributor

Hello @rahulmansharamani14,

Thanks for your pull request! A Core Committer will review your pull request soon. For code contributions, you can learn more about the review process here.

@cwarnermm cwarnermm self-requested a review November 4, 2024 14:12
@cwarnermm cwarnermm added 2: Editor Review Requires review by an editor preview-environment Allow the preview environment to be generated for Pull Requests coming from fork repositories labels Nov 4, 2024
Copy link

github-actions bot commented Nov 4, 2024

Newest code from rahulmansharamani14 has been published to preview environment for Git SHA 985b96e

@cwarnermm
Copy link
Member

@rahulmansharamani14 - It looks like all links are opening in new browser windows right now, rather than only external links.

@cwarnermm cwarnermm added the Awaiting Submitter Action Blocked on the author label Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2: Editor Review Requires review by an editor Awaiting Submitter Action Blocked on the author Contributor preview-environment Allow the preview environment to be generated for Pull Requests coming from fork repositories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Open all external links in a new tab/window
3 participants