Skip to content

Commit

Permalink
feat: toc支持h1
Browse files Browse the repository at this point in the history
  • Loading branch information
D-Sketon committed Jan 14, 2024
1 parent 3d5b4f0 commit 0d72ba8
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hexo-theme-reimu",
"version": "0.0.11",
"version": "0.1.0-alpha",
"description": "A Hakurei Reimu style Hexo theme",
"main": "index.js",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions source/css/_partial/highlight.styl
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ $line-numbers
border-radius: 10px
background-color: var(--highlight-scrollbar)

pre, code
pre, code, kbd
font-family: "Ubuntu Mono"
font-size: 95%
transition: all 0.3s ease

code
code, kbd
background: var(--color-code-background)
padding: 1px 5px
border-radius: 5px
Expand Down
12 changes: 11 additions & 1 deletion source/css/_partial/sidebar.styl
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ $menu-link
width: 5px
height: 5px

.toc
.sidebar-toc-wrapper
color: var(--color-link)
a, span
color: var(--color-link)
Expand Down Expand Up @@ -460,6 +460,16 @@ $menu-link
border-radius: 50%
opacity: 1

.toc-level-1
list-style: none

&:before
display: none
>a
width: 100%
display: inline-block
text-align: center

.toc-child
display: none;

Expand Down
6 changes: 4 additions & 2 deletions source/js/pjax_script.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,9 @@ var scrollIntoViewAndWait = (element) => {
});

(function () {
const navItems = getComputedStyle(document.getElementById('sidebar')).display === 'block' ? $('#sidebar .toc li') : $('#mobile-nav .toc li');
const navItems = getComputedStyle(document.getElementById('sidebar')).display === 'block' ?
$('#sidebar .sidebar-toc-wrapper li') :
$('#mobile-nav .sidebar-toc-wrapper li');
if (navItems.length === 0) return;

let activeLock = null;
Expand Down Expand Up @@ -238,7 +240,7 @@ var scrollIntoViewAndWait = (element) => {
if (!target) return;
if (target.hasClass('current')) return;

$('.toc .active').removeClass('active current');
$('.sidebar-toc-wrapper .active').removeClass('active current');

sections.each(function () {
$(this) && $(this).removeClass('active');
Expand Down

0 comments on commit 0d72ba8

Please sign in to comment.