fix: patch landscape2 links to open in new tab#130
Open
Tushar8466 wants to merge 2 commits into
Open
Conversation
Author
|
@Utkarsh-123github I have made the PR you can review it |
There was a problem hiding this comment.
Pull request overview
Adds a wrapper build script to work around landscape2 sanitization by post-processing the generated build/index.html and injecting a small JS snippet that forces rendered links to open in a new tab (including dynamically-rendered SPA content).
Changes:
- Introduces
build.shto runlandscape2 buildwith the repo’s standard inputs/outputs. - Injects a
MutationObserver-based script intobuild/index.htmlto settarget="_blank"+rel="noopener noreferrer"on links after DOM updates. - Makes the injection idempotent by removing the prior injected snippet before re-inserting.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
landscape2builds the site fromguide.ymland converts Markdown links to HTML<a>tags, but has these hard limitations:target="_blank"even if written as raw HTML inguide.yml<script>tags entirelyThere is no way to make
landscape2outputtarget="_blank"links — it's a built-in limitation of the tool.Solution
Since
guide.ymlitself can't fix this, we patch the generated output (build/index.html) afterlandscape2finishes building.What
build.shdoeslandscape2 build— exactly as beforebuild/index.htmlThe injected script uses a
MutationObserver— a browser API that watches for DOM changes. Since the landscape2 site is a SPA, guide content is rendered dynamically after page load. The observer detects new content in the DOM and immediately setstarget="_blank"on every link.Summary
landscape2sanitizes and stripstarget="_blank"build/index.htmlafter the build using PythonMutationObserverin JS setstarget="_blank"on all links dynamicallyScreen.Recording.2026-03-22.at.8.44.53.PM.mov
bash build.sh
instead oflandscape2 build ...` every time you rebuild |