Permalink
Browse files

Add TOC 增加文章目录

Show Table of Contents in default article page. Hide TOC via putting
"toc: false" before "---" at [post].md.
文章中默认显示目录,在文章---前输入toc: false关闭目录。
https://hexo.io/docs/helpers.html#toc
http://kuangqi.me/tricks/enable-table-of-contents-on-hexo/
  • Loading branch information...
MOxFIVE MOxFIVE
MOxFIVE authored and MOxFIVE committed Aug 19, 2015
1 parent dd31a5c commit c3eba7ac2e27d5ab2109f8b15338f2df8a97a604
Showing with 40 additions and 0 deletions.
  1. +2 −0 .gitignore
  2. +9 −0 themes/Yilia/layout/_partial/article.ejs
  3. +29 −0 themes/Yilia/source/css/_partial/article.styl
View
@@ -27,3 +27,5 @@ build/Release
node_modules
themes/Yilia/source/fancybox/Thumbs.db
*.db
@@ -24,6 +24,15 @@
<% if (post.excerpt && index){ %>
<%- post.excerpt %>
<% } else { %>
<!-- Table of Contents -->
<% if (!index && post.toc != false){ %>
<!-- 默认显示文章目录,在文章---前输入toc: false关闭目录 -->
<!-- Show TOC in default, Hide TOC via putting "toc: false" before "---" at [post].md -->
<div id="toc" class="toc-article">
<strong class="toc-title">文章目录</strong>
<%- toc(post.content) %>
</div>
<% } %>
<%- post.content %>
<% } %>
</div>
@@ -357,3 +357,32 @@
float: right;
}
}
/*toc*/
.toc-article {
background: #eee;
border-radius: 2.8%;
margin-left: 1em;
padding: 0.5em;
max-width: 28%
}
.toc-title {
}
#toc {
line-height: 1.5em;
font-size: .9em;
float right
}
#toc .toc {
padding: 0
}
#toc .toc li {
list-style-type: none
}
#toc ol {
margin-left: 0
}
#toc .toc-child {
padding-left: 1.25em
}

0 comments on commit c3eba7a

Please sign in to comment.