| 283 | // tree on GitHub. Injected once; guarded against re-injection on navigation. |
| 284 | |
| 285 | function injectVersionBanner(content) { |
| 286 | if (content.dataset.versionBanner === "true") return; |
| 287 | content.dataset.versionBanner = "true"; |
| 288 | |
| 289 | const version = (window.KMS_VERSION || "develop").trim(); |
| 290 | const treeUrl = `https://github.com/Cosmian/kms/tree/${version}`; |
| 291 | const isDev = version === "develop"; |
| 292 | |
| 293 | const banner = document.createElement("div"); |
| 294 | Object.assign(banner.style, { |
| 295 | display: "flex", |
| 296 | alignItems: "flex-start", |
| 297 | gap: "12px", |
| 298 | padding: "14px 18px", |
| 299 | margin: "0 0 28px", |
| 300 | borderRadius: "8px", |
| 301 | border: `1.5px solid ${isDev ? "#f57c00" : "#1565c0"}`, |
| 302 | background: isDev |
| 303 | ? "rgba(245,124,0,0.06)" |
| 304 | : "rgba(21,101,192,0.06)", |
| 305 | fontSize: "0.88em", |
| 306 | lineHeight: "1.6", |
| 307 | }); |
| 308 | |
| 309 | const icon = document.createElement("span"); |
| 310 | icon.textContent = isDev ? "⚠️" : "📖"; |
| 311 | icon.style.cssText = "font-size:1.3em;flex-shrink:0;margin-top:1px;"; |
| 312 | |
| 313 | const text = document.createElement("span"); |
| 314 | if (isDev) { |
| 315 | text.innerHTML = |
| 316 | `<strong>Development build</strong> — source links point to the ` + |
| 317 | `<a href="${treeUrl}" target="_blank" rel="noopener noreferrer">` + |
| 318 | `<code>develop</code> branch</a>. ` + |
| 319 | `Links may not match a released version.`; |
| 320 | } else { |
| 321 | text.innerHTML = |
| 322 | `This log index covers <strong>KMS ${version}</strong>. ` + |
| 323 | `Each file link points to the exact source line in ` + |
| 324 | `<a href="${treeUrl}" target="_blank" rel="noopener noreferrer">` + |
| 325 | `the <code>${version}</code> tree on GitHub</a>.`; |
| 326 | } |
| 327 | |
| 328 | banner.appendChild(icon); |
| 329 | banner.appendChild(text); |
| 330 | |
| 331 | // Insert before the <h1> (first heading in the article) |
| 332 | // Material MkDocs uses .md-content__inner / .md-typeset; mdBook uses <main> |
| 333 | const article = content.querySelector(".md-content__inner, article, .md-typeset, main") || content; |
| 334 | const h1 = article ? article.querySelector("h1") : null; |
| 335 | if (h1) { |
| 336 | h1.insertAdjacentElement("afterend", banner); |
| 337 | } else if (article) { |
| 338 | article.prepend(banner); |
| 339 | } |
| 340 | } |
| 341 | |
| 342 | // ── Main ────────────────────────────────────────────────────────────────── |