-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
116 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{% assign enable_toc = false %} | ||
{% if site.toc and page.toc %} | ||
{% if page.content contains '<h2' or page.content contains '<h3' %} | ||
{% assign enable_toc = true %} | ||
{% endif %} | ||
{% endif %} | ||
|
||
{% if enable_toc %} | ||
<section id="toc-leftbar-wrapper" class="d-none w-100 ps-0" style="flex-grow: 12; margin-bottom: 2rem;"> | ||
<hr style="width: 90%; margin: 2rem auto;"> | ||
<h2 class="panel-heading ps-3 mb-2">{{- site.data.locales[include.lang].panel.toc -}}</h2> | ||
<nav id="toc-leftbar"></nav> | ||
</section> | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,33 @@ | ||
export function toc() { | ||
function tocRightbar() { | ||
if (document.querySelector('main h2, main h3')) { | ||
// see: https://github.com/tscanlin/tocbot#usage | ||
tocbot.init({ | ||
tocSelector: '#toc', | ||
tocSelector: '#toc-rightbar', | ||
contentSelector: '.content', | ||
ignoreSelector: '[data-toc-skip]', | ||
headingSelector: 'h2, h3, h4', | ||
orderedList: false, | ||
scrollSmooth: false | ||
}); | ||
|
||
document.getElementById('toc-wrapper').classList.remove('d-none'); | ||
document.getElementById('toc-rightbar-wrapper').classList.remove('d-none'); | ||
} | ||
} | ||
|
||
function tocLeftbar() { | ||
if (document.querySelector('main h2, main h3')) { | ||
// see: https://github.com/tscanlin/tocbot#usage | ||
tocbot.init({ | ||
tocSelector: '#toc-leftbar', | ||
contentSelector: '.content', | ||
ignoreSelector: '[data-toc-skip]', | ||
headingSelector: 'h2, h3, h4', | ||
orderedList: false, | ||
scrollSmooth: false | ||
}); | ||
|
||
document.getElementById('toc-leftbar-wrapper').classList.remove('d-none'); | ||
} | ||
} | ||
|
||
export { tocLeftbar, tocRightbar }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1320,6 +1320,8 @@ search { | |
#topbar-wrapper { | ||
@include slide(top 0.2s ease); | ||
|
||
position: sticky; | ||
top: 0; | ||
left: 0; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters