Permalink
Browse files

add: settings for TOC (list_number, max_depth)

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

0 comments on commit 659f6ea

Please sign in to comment.