Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/h-enk/doks.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenk Verlinde <henk@ventizo.com>2022-07-05 12:37:00 +0300
committerGitHub <noreply@github.com>2022-07-05 12:37:00 +0300
commitfdae102373b2e640f88df88fb4458a314c443ecb (patch)
tree37c37b50e637016439e615ef931ed21a3e131923
parent93d9202bd6aa9d1505e567842f664406f623f558 (diff)
parentf9226af336e5fd5f8b15ffa071ece39c64b4e10c (diff)
Merge pull request #797 from h-enk/scroll-spy
🧪 Add scrollspy to toc pages as an option (experimental)
-rw-r--r--assets/scss/common/_dark.scss4
-rw-r--r--assets/scss/common/_global.scss8
-rw-r--r--config/_default/params.toml1
-rw-r--r--layouts/_default/baseof.html2
-rw-r--r--layouts/partials/sidebar/docs-toc.html6
5 files changed, 18 insertions, 3 deletions
diff --git a/assets/scss/common/_dark.scss b/assets/scss/common/_dark.scss
index 91de923..2f77262 100644
--- a/assets/scss/common/_dark.scss
+++ b/assets/scss/common/_dark.scss
@@ -571,6 +571,10 @@ $navbar-dark-active-color: $link-color-dark;
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;
+}
+
[data-dark-mode] .btn-light {
color: $link-color-dark;
background: $body-overlay-dark;
diff --git a/assets/scss/common/_global.scss b/assets/scss/common/_global.scss
index e1cee67..475ca6d 100644
--- a/assets/scss/common/_global.scss
+++ b/assets/scss/common/_global.scss
@@ -216,11 +216,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 adecfa3..2c2a2ca 100644
--- a/config/_default/params.toml
+++ b/config/_default/params.toml
@@ -106,6 +106,7 @@ lastMod = false
fullWidth = false
navbarSticky = true
toTopButton = false
+ scrollSpy = false # experimental; needs Bootstrap >= 5.2.0-beta1
[menu]
[menu.section]
diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html
index 509bb18..97d74f6 100644
--- a/layouts/_default/baseof.html
+++ b/layouts/_default/baseof.html
@@ -12,7 +12,7 @@
{{ .Scratch.Set "class" .Type -}}
{{ .Scratch.Add "class" " list" -}}
{{ end -}}
- <body class="{{ .Scratch.Get "class" }}">
+ <body class="{{ .Scratch.Get "class" }}"{{ if eq .Site.Params.options.scrollSpy true }} data-bs-spy="scroll" data-bs-target="#toc" data-bs-root-margin="0px 0px -90%" data-bs-smooth-scroll="true" tabindex="0"{{ end }}>
{{ partial "header/header.html" . }}
<div class="wrap container-{{ if .Site.Params.options.fullWidth }}fluid{{ else }}xxl{{ end }}" role="document">
<div class="content">
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 @@
</div>
<div class="page-links d-none d-xl-block">
<h3>On this page</h3>
- {{ .TableOfContents }}
+ {{ if eq .Site.Params.options.scrollSpy true -}}
+ {{ .TableOfContents | replaceRE "<nav id=\"TableOfContents\">" "<nav id=\"toc\">" | safeHTML }}
+ {{ else -}}
+ {{ .TableOfContents }}
+ {{ end -}}
</div>
{{ end -}}