From 8d833bd9319f3e6c28a0879a614ae0fa162d044b Mon Sep 17 00:00:00 2001 From: Henk Verlinde Date: Thu, 23 Jun 2022 20:15:51 +0200 Subject: [PATCH] feat: add scroll spy to toc pages as an option (experimental) --- assets/scss/common/_dark.scss | 4 ++++ assets/scss/common/_global.scss | 8 ++++++- config/_default/params.toml | 1 + layouts/_default/baseof.html | 2 +- layouts/partials/sidebar/docs-toc.html | 6 +++++- package-lock.json | 30 +++++++++++++++----------- package.json | 2 +- 7 files changed, 37 insertions(+), 16 deletions(-) diff --git a/assets/scss/common/_dark.scss b/assets/scss/common/_dark.scss index 4694fd5..2006c2f 100644 --- a/assets/scss/common/_dark.scss +++ b/assets/scss/common/_dark.scss @@ -570,3 +570,7 @@ $navbar-dark-active-color: $link-color-dark; [data-dark-mode] details summary::before { content: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='rgba%28222, 226, 230, 0.75%29' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M5 14l6-6-6-6'/%3e%3c/svg%3e"); } + +[data-dark-mode] #toc a.active { + color: $link-color-dark; +} diff --git a/assets/scss/common/_global.scss b/assets/scss/common/_global.scss index cbc8e41..f95c6ed 100644 --- a/assets/scss/common/_global.scss +++ b/assets/scss/common/_global.scss @@ -214,11 +214,17 @@ body { text-decoration: none; } -#TableOfContents ul { +#TableOfContents ul, +#toc ul { padding-left: 0; list-style: none; } +#toc a.active { + color: $primary; + font-weight: 500; +} + ::selection { background: rgba(212, 53, 159, 0.2); } diff --git a/config/_default/params.toml b/config/_default/params.toml index 5780d96..fc1c4cf 100644 --- a/config/_default/params.toml +++ b/config/_default/params.toml @@ -92,6 +92,7 @@ lastMod = false docsVersioning = false fullWidth = false navbarSticky = true + scrollSpy = true # experimental; needs Bootstrap >= 5.2.0-beta1 [menu] [menu.section] diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index b8b4273..a37c8c2 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -12,7 +12,7 @@ {{ .Scratch.Set "class" .Type -}} {{ .Scratch.Add "class" " list" -}} {{ end -}} - + {{ partial "header/header.html" . }}
diff --git a/layouts/partials/sidebar/docs-toc.html b/layouts/partials/sidebar/docs-toc.html index ba41c9a..60572b7 100644 --- a/layouts/partials/sidebar/docs-toc.html +++ b/layouts/partials/sidebar/docs-toc.html @@ -17,6 +17,10 @@
{{ end -}} diff --git a/package-lock.json b/package-lock.json index e60812b..36fbd24 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,7 +16,7 @@ "@fullhuman/postcss-purgecss": "^4.1", "auto-changelog": "^2.4", "autoprefixer": "^10.4", - "bootstrap": "^5.1", + "bootstrap": "^5.2.0-beta1", "clipboard": "^2.0", "eslint": "^8.18", "exec-bin": "^1.0.0", @@ -2247,16 +2247,22 @@ } }, "node_modules/bootstrap": { - "version": "5.1.3", - "resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.1.3.tgz", - "integrity": "sha512-fcQztozJ8jToQWXxVuEyXWW+dSo8AiXWKwiSSrKWsRB/Qt+Ewwza+JWoLKiTuQLaEPhdNAJ7+Dosc9DOIqNy7Q==", + "version": "5.2.0-beta1", + "resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.2.0-beta1.tgz", + "integrity": "sha512-6qbgs177WZEFY4SLQUq3tEHayYG80nfDmyTpdKi0MJqRMdS+HAoq24+YKfx6wf+nHY0rx8zrh477J1lFu4WzOA==", "dev": true, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/bootstrap" - }, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/twbs" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/bootstrap" + } + ], "peerDependencies": { - "@popperjs/core": "^2.10.2" + "@popperjs/core": "^2.11.5" } }, "node_modules/brace-expansion": { @@ -8519,9 +8525,9 @@ } }, "bootstrap": { - "version": "5.1.3", - "resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.1.3.tgz", - "integrity": "sha512-fcQztozJ8jToQWXxVuEyXWW+dSo8AiXWKwiSSrKWsRB/Qt+Ewwza+JWoLKiTuQLaEPhdNAJ7+Dosc9DOIqNy7Q==", + "version": "5.2.0-beta1", + "resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.2.0-beta1.tgz", + "integrity": "sha512-6qbgs177WZEFY4SLQUq3tEHayYG80nfDmyTpdKi0MJqRMdS+HAoq24+YKfx6wf+nHY0rx8zrh477J1lFu4WzOA==", "dev": true, "requires": {} }, diff --git a/package.json b/package.json index 25d73dd..1599b6d 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "@fullhuman/postcss-purgecss": "^4.1", "auto-changelog": "^2.4", "autoprefixer": "^10.4", - "bootstrap": "^5.1", + "bootstrap": "^5.2.0-beta1", "clipboard": "^2.0", "eslint": "^8.18", "exec-bin": "^1.0.0",