Permalink
Browse files

add: settings for TOC (list_number, max_depth)

  • Loading branch information...
1 parent c156638 commit 659f6eabe4922699a69bc583404c9f778b896535 @MOxFIVE committed Jul 4, 2016
Showing with 32 additions and 23 deletions.
  1. +5 −5 _config.yml
  2. +1 −3 layout/_partial/article.ejs
  3. +24 −14 layout/_partial/toc.ejs
  4. +1 −1 source/css/_partial/toc.styl
  5. +1 −0 source/css/_variables.styl
View
@@ -154,11 +154,11 @@ left_col_width: 300
copyright: true
# Table of contents | 文章目录
-toc: true
-
-# 目录中标题不换行
-# Keep TOC title on the same line |
-toc_nowrap: false
+toc:
+ on: true
+ list_number: true # 目录序号
+ max_depth: 3 # 1 - 6 (h1-h6) 目录最大级数
+ nowrap: false # Keep title on same line | 目录标题不换行
# 是否开启主页及加载头像时的动画效果
# Animation in Homepage and Loading avatar
@@ -56,9 +56,7 @@
<%- partial('post/nav') %>
<% } %>
</article>
-<% if (!index && ((post.toc != false && !is_page() && theme.toc) || post.toc)){ %>
- <%- partial('_partial/toc') %>
-<% } %>
+<%- partial('_partial/toc') %>
<% if (!index && theme.share.on && (post.share != false || post.share)){ %>
<%- partial('post/share') %>
@@ -1,16 +1,26 @@
-<div id="toc" class="toc-article">
- <strong class="toc-title"><%= __('toc.title') %></strong>
- <%- toc(post.content) %>
-</div>
-<style>
- .left-col .switch-btn,
- .left-col .switch-area {
- display: none;
- }
-</style>
+<% if (!index && ((post.toc != false && !is_page() && theme.toc.on) || post.toc)) { %>
+ <div id="toc" class="toc-article">
+ <strong class="toc-title"><%= __('toc.title') %></strong>
+ <% if ((theme.toc.list_number && post.toc_list_number != false) || post.toc_list_number) { %>
+ <%- toc(post.content) %>
+ <% } else { %>
+ <%- toc(post.content, {list_number: false}) %>
+ <% } %>
+ </div>
+ <style>
+ .left-col .switch-btn,
+ .left-col .switch-area {
+ display: none;
+ }
+ .toc-level-<%= theme.toc.max_depth %> i,
+ .toc-level-<%= theme.toc.max_depth %> ol {
+ display: none !important;
+ }
+ </style>
-<input type="button" id="tocButton" value="<%= __('toc.hide') %>" title="<%= __('tooltip.tocButton') %>">
+ <input type="button" id="tocButton" value="<%= __('toc.hide') %>" title="<%= __('tooltip.tocButton') %>">
-<script>
- yiliaConfig.toc = ["<%= __('toc.hide') %>", "<%= __('toc.show') %>", !!"<%= theme.toc_nowrap %>"];
-</script>
+ <script>
+ yiliaConfig.toc = ["<%= __('toc.hide') %>", "<%= __('toc.show') %>", !!"<%= theme.toc.nowrap %>"];
+ </script>
+<% } %>
@@ -72,7 +72,7 @@
margin 4px 0
- if hexo-config("toc_nowrap")
+ if toc-nowrap
a.toc-link
display inline-block
width 100%
@@ -74,6 +74,7 @@ toc-top = 378px
share = hexo-config("share.on")
search = hexo-config("search.on")
+toc-nowrap = hexo-config("toc.nowrap")
color-scheme = hexo-config("color_scheme")
background-image = hexo-config("background_image")

0 comments on commit 659f6ea

Please sign in to comment.