fi3ework / hexo-theme-archer

🎯 A smart and modern theme for Hexo.
https://fi3ework.github.io/hexo-theme-archer
MIT License
1.52k stars 273 forks source link

主页及page里的文章,能在显示tag之外还显示category么? #188

Closed shuyx closed 3 years ago

shuyx commented 5 years ago

提出你对主题的建议(Suggest your idea)

主题很喜欢,但有个问题,主页和page页面里面,文章都只显示tag,没有显示目录。虽然在侧边栏我可以使用目录查看,但我希望每篇文章都能显示目录,这个功能可以做到么?是哪里需要修改一下么?

冒昧打扰,希望回复,多谢多谢

提出你觉得可行的解决方案 [可选](Describe the solution you'd like)

提出其他的你考虑到的点(Describe alternatives you've considered)

其他

zchengsite commented 5 years ago

请问你是说每一篇文章页面右边显示的Catalog吗? https://zcheng.site/sshkeys.html 如果你的需求是上面链接里文章展示的,只需要在你需要写成Catalog的字段上写上id eg: <h3 id="第一部分">一、第一部分</h3> <h3 id="第二部分">二、第二部分</h3> <h3 id="第三部分">三、第三部分</h3>

LolipopJ commented 3 years ago

以博客推送为例,在文章顶部通过如下代码引入标签:

<!-- layout/_partial/base-background-image.ejs -->
<!-- 文章页标签  -->
<% if(page.tags.length) { %>
    <%- partial('base-title-tags', {
        currPost: page,
        className: 'post-intro-tags'}) %>
<% } %>

其中,base-title-tags 代码如下:

<div class= <%- className %> >
    <% currPost.tags.forEach(function (tag, i) { %>
        <a class="post-tag" href="javascript:void(0);" data-tags = "<%- tag.name %>"><%- tag.name %></a>
    <% }) %>
</div>

对于传入的 page 对象里的 tags 属性中的每个值,渲染了一个 <a class="post-tag" href="javascript:void(0);" data-tags = "<%- tag.name %>"><%- tag.name %></a> 元素。

参考此实现,您可以自行编写显示 Category 的代码。

未来我们可能会加上此功能,并由用户决定要不要在显示 Tags 的基础上,显示 Category 信息。