summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEltrac <hi@guhub.cn>2024-12-19 16:24:33 +0800
committerEltrac <hi@guhub.cn>2024-12-19 16:24:33 +0800
commitb4a540a7989727b7d5ca2691826eab31a1bb3415 (patch)
treec9e46ec5e592b563d9aee32eace520f166359af6
parent71b662c72350f978098f4418dae82f1a6e98ec41 (diff)
feat: style for toc list
-rw-r--r--assets/css/index.css55
-rw-r--r--hugo.toml1
-rw-r--r--layouts/partials/scripts.html2
3 files changed, 54 insertions, 4 deletions
diff --git a/assets/css/index.css b/assets/css/index.css
index 6978833d..0be9775a 100644
--- a/assets/css/index.css
+++ b/assets/css/index.css
@@ -629,12 +629,63 @@ a.blog-link img {
right: calc(50% + var(--page-width) / 2);
left: auto;
height: 100%;
- top: 10rem;
+ top: 12rem;
}
#toc {
+ /* position */
position: sticky;
- top: 3rem
+ top: 3rem;
+ /* styling */
+ font-size: 1rem;
+ padding: 0 2rem;
+}
+
+#toc ul, #toc ol {
+ margin-block-start: 0;
+ margin-block-end: 0;
+ padding-inline-start: 1rem;
+}
+
+#toc li {
+ list-style: none;
+}
+
+#toc li > a {
+ color: var(--secondary-text-color);
+ text-decoration: none;
+ transition: .3s;
+ display: inline-flex;
+ align-items: center;
+ gap: .5rem;
+}
+
+#toc li > a::before {
+ content: '';
+ display: inline-block;
+ width: 1rem;
+ height: .3rem;
+ background-color: var(--block-background-color);
+ border-radius: .2rem;
+}
+
+#toc li a:hover,
+#toc li.is-active-li > a {
+ color: var(--text-color);
+}
+
+#toc li.is-active-li > a::before {
+ background-color: var(--secondary-text-color);
+}
+
+#toc .toc-list {
+ overflow: hidden;
+ position: relative;
+ transition: .3s;
+}
+
+#toc .toc-list.is-collapsed {
+ max-height: 0
}
/* transition swup */
diff --git a/hugo.toml b/hugo.toml
index bcde2d79..efacda3a 100644
--- a/hugo.toml
+++ b/hugo.toml
@@ -21,7 +21,6 @@ favicon = "/favicon.png"
extraCSSFiles = [
'https://unpkg.com/@fancyapps/ui@5.0.36/dist/fancybox/fancybox.css',
- 'https://unpkg.com/tocbot@4.32.2/dist/tocbot.css',
'https://unpkg.com/@waline/client@v3/dist/waline.css'
]
externalJSFIles = [
diff --git a/layouts/partials/scripts.html b/layouts/partials/scripts.html
index 89be5e8d..ed791d4c 100644
--- a/layouts/partials/scripts.html
+++ b/layouts/partials/scripts.html
@@ -40,7 +40,7 @@ function loadToc() {
// Where to grab the headings to build the table of contents.
contentSelector: '#post-content',
// Which headings to grab inside of the contentSelector element.
- headingSelector: 'h2, h3',
+ headingSelector: 'h2, h3:not(blockquote > h3)',
// For headings inside relative or absolute positioned containers within content.
hasInnerContainers: true,
});