Skip to content

Commit 3479ed0

Browse files
committed
docs(sidebar): Add libtmux-mcp links and path-aware active detection
why: Update sidebar to include libtmux-mcp and pytest sub-links under tmux-python group, and upgrade JS to support path-aware active detection for sub-project URLs. what: - Switch tmux-python to indented layout with mcp and pytest sub-links - Replace hostname-only JS matching with URL-aware path prefix matching
1 parent c36519e commit 3479ed0

File tree

1 file changed

+25
-11
lines changed

1 file changed

+25
-11
lines changed

docs/_templates/sidebar/projects.html

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,14 @@
1313
</p>
1414
<p class="indented-block">
1515
<span class="project-name">tmux-python</span>
16-
<a class="internal" href="https://tmuxp.git-pull.com">tmuxp</a>
17-
(<a class="internal" href="https://libtmux.git-pull.com">libtmux</a>)
16+
<span class="indent">
17+
<a class="internal" href="https://tmuxp.git-pull.com">tmuxp</a>
18+
</span>
19+
<span class="indent">
20+
<a class="internal" href="https://libtmux.git-pull.com">libtmux</a>
21+
(<a class="internal" href="https://libtmux-mcp.git-pull.com">mcp</a>,
22+
<a class="internal" href="https://libtmux.git-pull.com/pytest-plugin/">pytest</a>)
23+
</span>
1824
</p>
1925

2026
<p class="indented-block">
@@ -56,15 +62,23 @@
5662
<script type="text/javascript">
5763
(() => {
5864
const sidebar = document.getElementById("sidebar-projects");
59-
sidebar.querySelectorAll(`a[href*="${window.location.hostname}"]`)
60-
.forEach((link) => {
61-
if (!link.classList.contains("active")) {
62-
const d = document.createElement('span');
63-
d.textContent = link.textContent;
64-
d.classList.add("active");
65-
link.parentNode.replaceChild(d, link);
66-
}
67-
});
65+
const loc = window.location;
66+
sidebar.querySelectorAll("a[href]").forEach((link) => {
67+
const url = new URL(link.href, loc.origin);
68+
const sameHost = url.hostname === loc.hostname;
69+
const hasPath = url.pathname.replace(/\/+$/, "").length > 0;
70+
// Links with a pathname: match origin + path prefix (e.g. /pytest-plugin/)
71+
// Links without: match hostname only (e.g. https://libtmux.git-pull.com)
72+
const isActive = hasPath
73+
? sameHost && loc.pathname.startsWith(url.pathname.replace(/\/+$/, ""))
74+
: sameHost;
75+
if (isActive && !link.classList.contains("active")) {
76+
const d = document.createElement('span');
77+
d.textContent = link.textContent;
78+
d.classList.add("active");
79+
link.parentNode.replaceChild(d, link);
80+
}
81+
});
6882
sidebar.classList.add('ready');
6983
})()
7084
</script>

0 commit comments

Comments
 (0)