Skip to content

Commit

Permalink
fix(toc): Use data attributes for toc
Browse files Browse the repository at this point in the history
Partially fixes: dillonzq#401

Signed-off-by: Khusika Dhamar Gusti <[email protected]>
  • Loading branch information
Khusika Dhamar Gusti committed Nov 27, 2020
1 parent 1281b13 commit 9151f85
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion assets/css/_partial/_single/_toc.scss
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
display: none;
margin: .8rem 0;

&[kept=true] {
&[data-kept=true] {
display: block;
}

Expand Down
2 changes: 1 addition & 1 deletion assets/js/theme.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/js/theme.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion layouts/posts/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ <h2 class="single-subtitle">{{ . }}</h2>

{{- /* Static TOC */ -}}
{{- if ne $toc.enable false -}}
<div class="details toc" id="toc-static" kept="{{ if $toc.keepStatic }}true{{ end }}">
<div class="details toc" id="toc-static" data-kept="{{ if $toc.keepStatic }}true{{ end }}">
<div class="details-summary toc-title">
<span>{{ T "contents" }}</span>
<span><i class="details-icon fas fa-angle-right"></i></span>
Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/js/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ class Theme {
initToc() {
const $tocCore = document.getElementById('TableOfContents');
if ($tocCore === null) return;
if (document.getElementById('toc-static').getAttribute('kept') || this.util.isTocStatic()) {
if (document.getElementById('toc-static').getAttribute('data-kept') || this.util.isTocStatic()) {
const $tocContentStatic = document.getElementById('toc-content-static');
if ($tocCore.parentElement !== $tocContentStatic) {
$tocCore.parentElement.removeChild($tocCore);
Expand Down

0 comments on commit 9151f85

Please sign in to comment.