Skip to content

Commit

Permalink
Increase toc heading levels to h4
Browse files Browse the repository at this point in the history
  • Loading branch information
otzslayer committed Jun 14, 2023
1 parent 697f4ed commit 2128083
Show file tree
Hide file tree
Showing 10 changed files with 415 additions and 9 deletions.
2 changes: 1 addition & 1 deletion _includes/toc.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% assign enable_toc = false %}
{% if site.toc and page.toc %}
{% if page.content contains '<h2' or page.content contains '<h3' %}
{% if page.content contains '<h2' or page.content contains '<h3' or page.content contains '<h4' %}
{% assign enable_toc = true %}
{% endif %}
{% endif %}
Expand Down
6 changes: 4 additions & 2 deletions _javascript/modules/components/toc.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
export function toc() {
if (document.querySelector('#core-wrapper h2,#core-wrapper h3')) {
if (
document.querySelector('#core-wrapper h2,#core-wrapper h3,#core-wrapper h4')
) {
// see: https://github.com/tscanlin/tocbot#usage
tocbot.init({
tocSelector: '#toc',
contentSelector: '.post-content',
ignoreSelector: '[data-toc-skip]',
headingSelector: 'h2, h3',
headingSelector: 'h2, h3, h4',
orderedList: false,
scrollSmooth: false
});
Expand Down
1 change: 1 addition & 0 deletions _sass/layout/archives.scss
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
margin-left: 2.5rem;
position: relative;
top: 0.1rem;
font-size: 1rem;

&:hover {
border-bottom: none;
Expand Down
5 changes: 5 additions & 0 deletions _sass/layout/post.scss
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,11 @@ h1 + .post-meta {
a {
padding-left: 2rem;
}
ul {
a {
padding-left: 3rem;
}
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion assets/js/dist/categories.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion assets/js/dist/commons.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2128083

Please sign in to comment.