shenliyang / hexo-theme-snippet

Snippet 简洁而不简单,也许是一款你寻找已久的hexo主题
https://snippet.shenliyang.com/
MIT License
1.09k stars 208 forks source link

tags 以及categories 页面显示不正确 #112

Closed eacdy closed 5 years ago

eacdy commented 5 years ago

例如: image image

建议将layout/page.ejs 修改为:

<div class="about">
    <%if(page.type=='tags'){%>
        <article class="post">
            <h1 class="post-head">共计<%- site.tags.length%>个标签</h1>
            <div class="post-body">
                <%- tagcloud({min_font: 14, max_font: 30, amount: 200, color: true, start_color: '#ccc', end_color: '#111'}) %>
            </div>
        </article>
    <% } else if(page.type=='categories') { %>
        <article class="post">
            <h1 class="post-head">共计<%- site.categories.length%>个分类</h1>
            <div class="post-body">
            <% site.categories.forEach(function (item) {%>
                <li class="post-items" >
                        <a href="/<%- item.path%>" title="<%- item.name%>" target="_blank">
                            <%- item.name%>
                        </a>
                </li>
            <%})%>
            </div>
        </article>
    <% } else{ %>
        <article class="post">
            <h1 class="post-head">关于我</h1>
            <div class="post-body">
                <%- page.content %>
            </div>
        </article>
    <%}%>
</div>

修改后结果: image ![Uploading image.png…]()

shenliyang commented 5 years ago

已经收到,非常感谢您的反馈

smartlin commented 5 years ago

已经收到,非常感谢您的反馈

这个bug在新版本还是未得到修复

eacdy commented 5 years ago

@smartlin 我修复了https://github.com/itmuch/hexo-theme-itmuch

shenliyang commented 5 years ago

@smartlin 您好,我来说明一下这个问题 当使用主题访问,域名+/tags 或 域名+ /categories 若访问404,是正常情况的。因为这些路径本不属于主题或者Hexo框架的一部分。而是由用户主动新建页面扩展而来。

Hexo 有三种默认布局:post、page 和 draft,如果要新建页面:

# hexo new 布局类型  标题
$ hexo new [layout] <title>

如果要实现以上内容,您可以参照 @eacdy 方式 首先,新建页面,当然,这个页面名称叫什么都可以,比如:tag | tags | mytags等,按以下命令格式:

 hexo new page tags 和 hexo new page categories

然后,在page.ejs中添加eacdy内容,并且要到新建的页面,增加type字段,即可实现功能

注意:如果修改page.ejs后,以后再新建页面内容都会已修改为主。可根据自己情况而定

最后,再次感谢@smartlin 的反馈和@eacdy的方案