Skip to content

Commit

Permalink
feat: Add min_depth option to toc
Browse files Browse the repository at this point in the history
  • Loading branch information
liuyib committed Feb 6, 2020
1 parent 576f177 commit 89bb869
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
12 changes: 7 additions & 5 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -309,15 +309,17 @@ social_setting:
toc:
enable: true
# Automatically add list number to toc.
number: true
list_number: true
# If true, all words will be placed on the next lines when they overflow.
wrap: true
# If true, the toc of post will always be displayed, rather than the activated part of it.
expand_all: false
# Maximum heading depth of generated toc. You can set it in the
# post through `toc_max_depth` in Front-matter.
# e.g. value: 3, will use h1~3 to generated toc.
max_depth: 4
# Minimum heading depth of generated toc.
# You can also set it in Front-matter by `toc_max_depth`.
min_depth: 1
# You can also set it in Front-matter by `toc_min_depth`.
# Maximum heading depth of generated toc.
max_depth: 6

# Subscribe of email and rss.
feed:
Expand Down
3 changes: 2 additions & 1 deletion layout/_partials/sidebar/sidebar.pug
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ if isShowToc
section.sidebar-toc(class=`${isShowToc ? "" : "hide"}`)
if page.content
- var tocMaxDepth = page.toc_max_depth || theme.toc.max_depth || 6;
div!= toc(page.content, {list_number: theme.toc.number, max_depth: tocMaxDepth})
- var tocMinDepth = page.toc_min_depth || theme.toc.min_depth || 1;
div!= toc(page.content, {list_number: theme.toc.list_number, min_depth: tocMinDepth, max_depth: tocMaxDepth})

<!-- ov = overview -->
section.sidebar-ov(class=`${isShowToc ? "hide" : ""}`)
Expand Down

0 comments on commit 89bb869

Please sign in to comment.