Open zhiweihuang opened 10 years ago
@zhiweihuang 你发的截图是哪款主题的?发个链接我参考。
@zhiweihuang 这个功能没有太多人需要,你可以自己参考pacman修改一下。
<% if(post.toc !== false && toc(post.content)){ %>
<div id="toc" class="toc-article">
<%- toc(post.content)%>
</div>
<% } %>
这个我自己加了,是hexo自带的toc功能,自己改下css就好
具体要怎么修改呢?新手表示亚历山大……
2014-08-30 22:59 GMT+08:00 Yangxufeng.Zhao notifications@github.com:
<% if(post.toc !== false && toc(post.content)){ %> <div id="toc" class="toc-article"> <%- toc(post.content)%> </div> <% } %>
这个我自己加了,是hexo自带的toc功能,自己改下css就好
— Reply to this email directly or view it on GitHub https://github.com/xiangming/landscape-plus/issues/16#issuecomment-53960682 .
layout/_partial/article.ejs 21行,如果没有改动过的话
<% } else { %>
<%- post.content %>
<% } %>
改成
<% } else { %>
<% if(post.toc !== false && toc(post.content)){ %>
<div id="toc" class="toc-article">
<%- toc(post.content)%>
</div>
<% } %>
<%- post.content %>
<% } %>
然后记得定义toc-article样式,名字可以你自己随意改
@joysboy 好评!
@joysboy 非常感谢你的解答。我按照你的方法修改了article.ejs,也在css使用了你提供的文件定义了toc,可是生成后显示效果却很奇怪,目录不是以区块形式居右显示的,具体参见下图,还望解答一二。
你css里没有定义float right
吧
表示我也想要这功能
有人搞定了吗,求完整教程啊。
@nshen @zhiweihuang 可以看下我写的"只需三步,添加文章目录模块 ",因为之前对主题修改的地方太多了,没办法请求合并到源库中。
@nshen @zhiweihuang 我写了一篇教程,希望能帮到助你。 为Hexo博文添加文章目录
这个功能确实可以内嵌在里面,然后自己选择开不开,这样也就不用自己折腾了。
Just like this: