From 65dfdc802505063e19a20cc492a9ec4eb57f5ab3 Mon Sep 17 00:00:00 2001 From: liuzhihang Date: Fri, 14 Oct 2022 22:43:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20toc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/assets/zhheo/zhheoblog.css | 6 +- templates/modules/widgets/toc.html | 51 ++++++++++ templates/post.html | 146 ++++----------------------- 3 files changed, 72 insertions(+), 131 deletions(-) create mode 100644 templates/modules/widgets/toc.html diff --git a/templates/assets/zhheo/zhheoblog.css b/templates/assets/zhheo/zhheoblog.css index daf62177..a10917d2 100644 --- a/templates/assets/zhheo/zhheoblog.css +++ b/templates/assets/zhheo/zhheoblog.css @@ -2242,7 +2242,7 @@ blockquote footer cite::before { } } -#aside-content #card-toc .toc-content .toc-item.active .toc-child { +#aside-content #card-toc .toc-content .toc-list-item.active .toc-child { display: block } @@ -9031,11 +9031,11 @@ a.article-meta__categories:hover { font-size: 20px } -[data-theme=dark].toc .toc-item.active .toc-link .toc-text { +[data-theme=dark].toc-list .toc-list-item.active .toc-link .toc-text { color: var(--heo-white) } -#aside-content #card-toc .toc-content .toc-item.active .toc-link { +#aside-content #card-toc .toc-content .toc-list-item.active .toc-link { opacity: 1; border-radius: 8px } diff --git a/templates/modules/widgets/toc.html b/templates/modules/widgets/toc.html new file mode 100644 index 00000000..f30a4f6f --- /dev/null +++ b/templates/modules/widgets/toc.html @@ -0,0 +1,51 @@ + + + + + +
+
文章目录
+ +
+ +
+ \ No newline at end of file diff --git a/templates/post.html b/templates/post.html index 49f296ed..94f3a6e8 100644 --- a/templates/post.html +++ b/templates/post.html @@ -12,40 +12,9 @@ - - - + - headerId = headerId.toLowerCase(); - if (idArr[headerId]) { // id已经存在 - $(this).attr('id', headerId + '-' + idArr[headerId]); - idArr[headerId]++; - } else { // id未存在 - idArr[headerId] = 1; - $(this).attr('id', headerId); - } - }); - tocbot.init({ - // 添加到哪里 - tocSelector: '.toc-item toc-level', - // 针对那个id标签 - contentSelector: content, - // 滚动跟随 - positionFixedClass: 'is-position-fixed', - positionFixedSelector: '.toc', - // 需要解析的标题 - headingSelector: headerEl - - }); - }); -
-
@@ -322,7 +210,7 @@
@@ -467,7 +355,7 @@
- 本文是原创文章,采用 CC BY-NC-ND 4.0 协议,完整转载请注明来自 CC BY-NC-ND 4.0 协议,完整转载请注明来自
@@ -531,16 +419,18 @@
-
-
文章目录
- -
+
+ + + + + + + + + + +