From b03ed840fc5d92044b70d0cff517bf4ceb9651bf Mon Sep 17 00:00:00 2001
From: Shane <6071159+smashedr@users.noreply.github.com>
Date: Fri, 28 Nov 2025 21:04:21 -0800
Subject: [PATCH 1/2] Add external-links.js
---
docs/javascripts/external-links.js | 37 ++++++++++++++++++++++++++++++
zensical.toml | 6 ++---
2 files changed, 40 insertions(+), 3 deletions(-)
create mode 100644 docs/javascripts/external-links.js
diff --git a/docs/javascripts/external-links.js b/docs/javascripts/external-links.js
new file mode 100644
index 0000000..5d5f823
--- /dev/null
+++ b/docs/javascripts/external-links.js
@@ -0,0 +1,37 @@
+document.addEventListener('DOMContentLoaded', domContentLoaded)
+
+const observer = new MutationObserver(mutationObserver)
+
+function domContentLoaded() {
+ for (const el of document.querySelectorAll('a')) {
+ processLink(el)
+ }
+ observer.observe(document, {
+ childList: true,
+ subtree: true,
+ })
+}
+
+function mutationObserver(mutationList) {
+ // console.debug('mutationList:', mutationList)
+ for (const mutation of mutationList) {
+ // console.debug('mutation:', mutation)
+ mutation.addedNodes.forEach((el) => {
+ // console.debug('el:', el)
+ if (el.classList?.contains('md-container')) {
+ for (const el of document.querySelectorAll('a')) {
+ processLink(el)
+ }
+ }
+ })
+ }
+}
+
+function processLink(el) {
+ // console.debug('checking el:', el)
+ if (el.host !== window.location.host) {
+ // console.debug('updating el:', el)
+ el.target = '_blank'
+ el.rel = 'noopener'
+ }
+}
diff --git a/zensical.toml b/zensical.toml
index a6a7e2b..4fb231f 100644
--- a/zensical.toml
+++ b/zensical.toml
@@ -12,9 +12,9 @@ site_url = "https://zensical-action.cssnr.com/"
# https://zensical.org/docs/setup/basics/#copyright
copyright = """
-Zensical Action Docs
+Zensical Action Docs
-Built with Zensical
+Built with Zensical
"""
# https://zensical.org/docs/setup/navigation/
@@ -29,7 +29,7 @@ nav = [
#extra_css = ["assets/stylesheets/extra.css"]
# https://zensical.org/docs/customization/#additional-javascript
-#extra_javascript = ["assets/javascript/extra.js"]
+extra_javascript = ["javascripts/external-links.js"]
# ----------------------------------------------------------------------------
# Section for configuring theme options
From d3acac4e809ef4892db9c01e5bd2458ff8933d30 Mon Sep 17 00:00:00 2001
From: Shane <6071159+smashedr@users.noreply.github.com>
Date: Fri, 28 Nov 2025 21:10:04 -0800
Subject: [PATCH 2/2] Add Comment
---
docs/javascripts/external-links.js | 3 +++
1 file changed, 3 insertions(+)
diff --git a/docs/javascripts/external-links.js b/docs/javascripts/external-links.js
index 5d5f823..de1d19e 100644
--- a/docs/javascripts/external-links.js
+++ b/docs/javascripts/external-links.js
@@ -1,3 +1,5 @@
+// Open External Links in New Tab
+
document.addEventListener('DOMContentLoaded', domContentLoaded)
const observer = new MutationObserver(mutationObserver)
@@ -19,6 +21,7 @@ function mutationObserver(mutationList) {
mutation.addedNodes.forEach((el) => {
// console.debug('el:', el)
if (el.classList?.contains('md-container')) {
+ // console.debug('md-container:', el)
for (const el of document.querySelectorAll('a')) {
processLink(el)
}