From e94787a4f2633aee6578d54ad1bcbd97384634e4 Mon Sep 17 00:00:00 2001 From: Weicao-CatilGrass <1992414357@qq.com> Date: Fri, 12 Jun 2026 20:14:10 +0800 Subject: Add prev/next page navigation plugin and styles --- docs/_zh_CN/index.html | 2 + docs/css/dark.css | 10 ++++ docs/css/doc-nav.css | 47 ++++++++++++++++ docs/doc.html | 2 + docs/scripts/docsify-plugin-prevnext.js | 95 +++++++++++++++++++++++++++++++++ 5 files changed, 156 insertions(+) create mode 100644 docs/css/doc-nav.css create mode 100644 docs/scripts/docsify-plugin-prevnext.js (limited to 'docs') diff --git a/docs/_zh_CN/index.html b/docs/_zh_CN/index.html index 66a8a9a..c6c13e6 100644 --- a/docs/_zh_CN/index.html +++ b/docs/_zh_CN/index.html @@ -28,6 +28,7 @@ href="../css/dark.css" disabled /> +
@@ -88,6 +89,7 @@ + diff --git a/docs/css/dark.css b/docs/css/dark.css index b14f3dc..a9791bd 100644 --- a/docs/css/dark.css +++ b/docs/css/dark.css @@ -915,3 +915,13 @@ section.cover blockquote > p > a { section.cover blockquote > p > a:hover { color: #d4a84b; } + +/* ── Prev/Next page navigation (dark) ── */ +.page-nav a { + border-color: #d4a84b; + color: #d4a84b; + background: transparent; +} +.page-nav a:hover { + background: rgba(212, 168, 75, 0.08); +} diff --git a/docs/css/doc-nav.css b/docs/css/doc-nav.css new file mode 100644 index 0000000..a31f1aa --- /dev/null +++ b/docs/css/doc-nav.css @@ -0,0 +1,47 @@ +/* Prev/Next page navigation + Light theme — matches docs/css/light.css cover buttons */ +.page-nav { + display: flex; + margin-top: 0; + gap: 0; +} +.page-nav a { + display: inline-flex; + align-items: center; + gap: 8px; + padding: 16px 24px; + border: 1px solid #b8943e; + border-radius: 2px; + text-decoration: none; + color: #b8943e; + font-size: 15px; + background: transparent; + transition: all 0.15s ease; + flex: 1 1 50%; + max-width: 50%; + box-sizing: border-box; +} +.page-nav a:hover { + background: rgba(184, 148, 62, 0.1); +} +.page-nav .nav-prev { + justify-content: flex-start; + margin-right: 8px; +} +.page-nav .nav-next { + justify-content: flex-end; + margin-left: auto; +} +.page-nav a:only-child { + max-width: 50%; +} +.page-nav .nav-label { + font-size: 12px; + opacity: 0.6; +} +.page-nav .nav-title { + font-weight: 600; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} diff --git a/docs/doc.html b/docs/doc.html index 0897109..ea5d7ad 100644 --- a/docs/doc.html +++ b/docs/doc.html @@ -23,6 +23,7 @@ + @@ -91,6 +92,7 @@ + diff --git a/docs/scripts/docsify-plugin-prevnext.js b/docs/scripts/docsify-plugin-prevnext.js new file mode 100644 index 0000000..c80f17c --- /dev/null +++ b/docs/scripts/docsify-plugin-prevnext.js @@ -0,0 +1,95 @@ +/*! + * docsify-plugin-prevnext + * Auto-generates previous/next page navigation based on sidebar order. + */ +(function () { + function install(hook, vm) { + hook.doneEach(function () { + var nav = document.querySelector(".page-nav"); + if (nav) nav.remove(); + + function navigate(path) { + window.location.hash = "#/" + (path || ""); + } + + var sidebarLinks = document.querySelectorAll(".sidebar-nav li a"); + if (!sidebarLinks.length) return; + + var currentPath = vm.route.path; + var links = []; + sidebarLinks.forEach(function (a) { + var href = a.getAttribute("href"); + if (!href) return; + if (href.startsWith("http")) return; + if (href.indexOf("?id=") !== -1) return; // skip sub-headings + var path = href.startsWith("#") ? href.slice(1) : href; + if (path.startsWith("/")) path = path.slice(1); + if (path === "" || path === "/") path = "README"; + links.push({ path: path, text: a.textContent.trim() }); + }); + + function normalize(p) { + return p.replace(/\.md$/g, "").replace(/^\/+|\/+$/g, ""); + } + + // Treat root path as README + var cur = normalize(currentPath) || "README"; + var idx = -1; + for (var i = 0; i < links.length; i++) { + if (normalize(links[i].path) === cur) { + idx = i; + break; + } + } + + if (idx === -1) return; + + var prevLink = idx > 0 ? links[idx - 1] : null; + var nextLink = idx < links.length - 1 ? links[idx + 1] : null; + + // Build nav HTML + var html = ""; + if (prevLink) { + html += + '' + + '"; + } + if (nextLink) { + html += + '' + + '"; + } + + if (!html) return; + + nav = document.createElement("div"); + nav.className = "page-nav"; + nav.innerHTML = html; + + // Attach click handlers via event delegation + nav.addEventListener("click", function (e) { + var target = e.target.closest("a"); + if (!target) return; + var path = target.getAttribute("data-nav"); + if (path) { + e.preventDefault(); + navigate(decodeURIComponent(path)); + } + }); + + var section = document.querySelector(".markdown-section"); + if (section) section.appendChild(nav); + }); + } + + window.$docsify = window.$docsify || {}; + window.$docsify.plugins = (window.$docsify.plugins || []).concat(install); +})(); -- cgit