Skip to content

Commit d121fde

Browse files
committed
feat(docs): add header script count badge and include setup/shared docs in nav
1 parent 172f37c commit d121fde

3 files changed

Lines changed: 135 additions & 0 deletions

File tree

docs/javascripts/script-count.js

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
(() => {
2+
const BADGE_ID = "script-total-badge";
3+
4+
function normalizePath(href) {
5+
try {
6+
const url = new URL(href, window.location.href);
7+
let path = url.pathname || "";
8+
9+
if (!path) {
10+
return "";
11+
}
12+
13+
path = path.replace(/\/{2,}/g, "/");
14+
if (path.startsWith("scripts/")) {
15+
path = `/${path}`;
16+
}
17+
18+
return path.replace(/\/+$/, "");
19+
} catch {
20+
return "";
21+
}
22+
}
23+
24+
function getScriptDocCount() {
25+
const paths = new Set();
26+
27+
document.querySelectorAll("a[href]").forEach((anchor) => {
28+
const href = anchor.getAttribute("href");
29+
if (!href || href.startsWith("#")) {
30+
return;
31+
}
32+
33+
const path = normalizePath(href);
34+
if (!path || !path.includes("/scripts/")) {
35+
return;
36+
}
37+
38+
paths.add(path);
39+
});
40+
41+
return paths.size;
42+
}
43+
44+
function renderBadge() {
45+
const container = document.querySelector("header .ml-auto");
46+
if (!container) {
47+
return;
48+
}
49+
50+
const count = getScriptDocCount();
51+
if (count <= 0) {
52+
return;
53+
}
54+
55+
let badge = document.getElementById(BADGE_ID);
56+
if (!badge) {
57+
badge = document.createElement("span");
58+
badge.id = BADGE_ID;
59+
badge.className = "script-total-badge";
60+
container.prepend(badge);
61+
}
62+
63+
badge.textContent = `Total Scripts: ${count}`;
64+
badge.setAttribute("aria-label", `Total scripts ${count}`);
65+
}
66+
67+
if (document.readyState === "loading") {
68+
document.addEventListener("DOMContentLoaded", renderBadge, { once: true });
69+
} else {
70+
renderBadge();
71+
}
72+
73+
window.addEventListener("load", renderBadge);
74+
})();

docs/stylesheets/extra.css

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,26 @@ article .typography pre.is-copied .code-copy-button {
7777
footer .text-muted-foreground.w-full.text-center.text-xs.leading-loose.sm\:text-sm {
7878
display: none;
7979
}
80+
81+
/* Header badge showing the total script count from docs navigation links. */
82+
.script-total-badge {
83+
display: inline-flex;
84+
align-items: center;
85+
justify-content: center;
86+
height: 1.75rem;
87+
padding: 0 0.65rem;
88+
border: 1px solid var(--color-border);
89+
border-radius: 999px;
90+
background-color: var(--color-secondary);
91+
color: var(--color-secondary-foreground);
92+
font-size: 0.72rem;
93+
font-weight: 600;
94+
line-height: 1;
95+
white-space: nowrap;
96+
}
97+
98+
@media (max-width: 767px) {
99+
.script-total-badge {
100+
display: none;
101+
}
102+
}

mkdocs.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ extra_css:
2121

2222
extra_javascript:
2323
- javascripts/code-copy.js
24+
- javascripts/script-count.js
2425

2526
markdown_extensions:
2627
- admonition
@@ -121,6 +122,7 @@ nav:
121122
- repo-healthcheck.sh: scripts/git/repo-healthcheck.md
122123
- clean-stale-branches.sh: scripts/git/clean-stale-branches.md
123124
- setup/local:
125+
- cleanup.sh: scripts/setup/local/cleanup.md
124126
- install-cli-tools.sh: scripts/setup/local/install-cli-tools.md
125127
- setup-shell.sh: scripts/setup/local/setup-shell.md
126128
- setup-ssh.sh: scripts/setup/local/setup-ssh.md
@@ -132,10 +134,26 @@ nav:
132134
- setup/runner:
133135
- bootstrap-linux-runner.sh: scripts/setup/runner/bootstrap-linux-runner.md
134136
- bootstrap-macos-runner.sh: scripts/setup/runner/bootstrap-macos-runner.md
137+
- cleanup.sh: scripts/setup/runner/cleanup.md
138+
- configure.sh: scripts/setup/runner/configure.md
135139
- install-docker.sh: scripts/setup/runner/install-docker.md
136140
- install-k8s-tools.sh: scripts/setup/runner/install-k8s-tools.md
137141
- install-cloud-clis.sh: scripts/setup/runner/install-cloud-clis.md
138142
- runner-healthcheck.sh: scripts/setup/runner/runner-healthcheck.md
143+
- setup/ci-agent:
144+
- cleanup.sh: scripts/setup/ci-agent/cleanup.md
145+
- configure.sh: scripts/setup/ci-agent/configure.md
146+
- setup/kube-workstation:
147+
- cleanup.sh: scripts/setup/kube-workstation/cleanup.md
148+
- install.sh: scripts/setup/kube-workstation/install.md
149+
- verify.sh: scripts/setup/kube-workstation/verify.md
150+
- setup/db-tools:
151+
- cleanup.sh: scripts/setup/db-tools/cleanup.md
152+
- configure.sh: scripts/setup/db-tools/configure.md
153+
- verify.sh: scripts/setup/db-tools/verify.md
154+
- setup/security-tools:
155+
- cleanup.sh: scripts/setup/security-tools/cleanup.md
156+
- verify.sh: scripts/setup/security-tools/verify.md
139157
- shared/core:
140158
- log-info.sh: scripts/shared/core/log-info.md
141159
- log-warn.sh: scripts/shared/core/log-warn.md
@@ -154,3 +172,23 @@ nav:
154172
- dry-run.sh: scripts/shared/safety/dry-run.md
155173
- confirm-dangerous.sh: scripts/shared/safety/confirm-dangerous.md
156174
- audit-event.sh: scripts/shared/safety/audit-event.md
175+
- shared/logging:
176+
- doc.sh: scripts/shared/logging/doc.md
177+
- example.sh: scripts/shared/logging/example.md
178+
- test.sh: scripts/shared/logging/test.md
179+
- shared/validation:
180+
- doc.sh: scripts/shared/validation/doc.md
181+
- example.sh: scripts/shared/validation/example.md
182+
- test.sh: scripts/shared/validation/test.md
183+
- shared/retry:
184+
- doc.sh: scripts/shared/retry/doc.md
185+
- example.sh: scripts/shared/retry/example.md
186+
- test.sh: scripts/shared/retry/test.md
187+
- shared/timeout:
188+
- doc.sh: scripts/shared/timeout/doc.md
189+
- example.sh: scripts/shared/timeout/example.md
190+
- test.sh: scripts/shared/timeout/test.md
191+
- shared/lock:
192+
- doc.sh: scripts/shared/lock/doc.md
193+
- example.sh: scripts/shared/lock/example.md
194+
- test.sh: scripts/shared/lock/test.md

0 commit comments

Comments
 (0)