Skip to content

Commit

Permalink
fix: open ext. links in new window code not dry (#238)
Browse files Browse the repository at this point in the history
  • Loading branch information
wesleyboar authored Sep 19, 2023
1 parent 1fe379a commit 066ff3d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ node_modules

# Fractal
demo
## Files used directly by demo but not clients, yet provided via dist
dist/_utils
## Empty file touched after auto-rebuild to trigger server live-refresh */
fractal.server.refresh.css

Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
"build": "npm run build:css && npm run build:demo",
"build:css": "bin/build.js --build-id=$npm_config_build_id",
"postbuild:css": "rm -rf dist/fonts && cp -r src/lib/fonts dist/fonts",
"prebuild:demo": "rm -rf dist/_utils && cp -r src/lib/_utils dist/_utils",
"prestart": "npm run prebuild:demo",
"build:demo": "fractal build",
"test": "bin/test.js && echo \"Test output at 'dist/_tests' (compare to test input)\"",
"build:watch": "npm run build:css && touch src/lib/_imports/fractal.server.refresh.css",
Expand Down
7 changes: 1 addition & 6 deletions src/lib/_imports/components/admonition/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,4 @@ To style ["Admonition" messages][rtd-admonition].
[rtd-admonition]: https://learning-readthedocs.readthedocs.io/en/latest/Options/admonition.html "ReadTheDocs: Admonition"

<script>
/* To open external links in new window */
Array.from(document.links)
.filter(link => link.hostname != window.location.hostname)
.forEach(link => link.target = '_blank');
</script>
<script src="{{path '/assets/_utils/js/open-ext-links-in-new-window.js'}}" />
4 changes: 4 additions & 0 deletions src/lib/_utils/js/open-ext-links-in-new-window.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* To open external links in new window */
Array.from(document.links)
.filter(link => link.hostname != window.location.hostname)
.forEach(link => link.target = '_blank');

0 comments on commit 066ff3d

Please sign in to comment.