上一次在修改了分类目录的样式之后,犯了一个巨大的错误,导致分类目录里会显示所有文章。

按计划,我需要在分类目录里根据发布时间对相关文章进行排序,同时还要能够显示status:secret的文章。结果脑子一热,忘记了在get_data函数中增加「仅在分类文件夹中搜索」的条件。

查询Farbox官方网站,得到以下说明:

cateogry
当URL路径为/any_thing/的时候,会去尝试获得一个对应的folder。注意,此时的必须要以/结尾
等价于get_doc(path=get_request_path(offset=1))

遂根据此说法修改分类目录模板如下,问题迎刃而解。

body
    block content
        div#posts
                ul.list-with-title
                entries = get_data(type='post', path=get_request_path(offset=1), status=['public', 'secret'], limit=20).group('-date:year')
                    for year, posts in entries
                                div.listing-title= year
                                    ul.listing
                                        for post in posts
                                            .listing-item
                                                 .listing-post
                                                        a(href=post.url, title=post.title)= post.title
                                                              div.post-time
                                                                      span.date= post.date.format("%m-%d")