提交 9c0d7336 编写于 作者: EvanOne(文一)'s avatar EvanOne(文一)

refactor: Optimizing the order of posts in timeline

上级 6d4149cc
......@@ -388,10 +388,6 @@ sidebar:
width: 280px
```
::: danger <Badge text="Deprecated" type="error"/>
该配置项的 `width` 属性在 `v1.2.0` 版本中移除。
:::
## 文章目录 <Badge text="Stable"/>
修改主题配置文件:
......
mixin postTimeline(posts)
section.post-timeline
- var year, tmpYear
- posts.each(function (post) {
- var sortPosts = []
//- Sort posts by date in descending order.
each post in posts
if (sortPosts.length === 0)
- sortPosts.push(post)
else
each _post, index in sortPosts
- var isBigTime = new Date(post.date).getTime() > new Date(_post.date).getTime();
if (post.top)
if (!_post.top || (new Date(post.date).getTime() > new Date(_post.date).getTime()))
- sortPosts.splice(index, 0, post)
- break
else if (index + 1 === sortPosts.length)
- sortPosts.push(post)
- break
else
if (!_post.top && (new Date(post.date).getTime() > new Date(_post.date).getTime()))
- sortPosts.splice(index, 0, post)
- break
else if (index + 1 === sortPosts.length)
- sortPosts.push(post)
- break
each post in sortPosts
if post.date
- tmpYear = full_date(post.date, "YYYY")
......@@ -20,4 +44,3 @@ mixin postTimeline(posts)
if post.top
include ../_partials/widgets/sticky-top.pug
- })
......@@ -6,7 +6,7 @@ block content
div.archive
div.archive-total= site.posts.length === 0 ? __("page.posts-empty") : _p("page.posts-total", site.posts.length)
+postTimeline(theme.post_list.paginate.archives ? page.posts : site.posts)
+postTimeline(theme.post_list.paginate.archives ? page.posts.data : site.posts.data)
if theme.post_list.paginate.archives
include ./_partials/widgets/pagination.pug
......@@ -8,6 +8,6 @@ block content
span= __("page.categories") + " -- "
span= page.category
+postTimeline(page.posts)
+postTimeline(page.posts.data)
include ./_partials/widgets/pagination.pug
......@@ -8,6 +8,6 @@ block content
span= __("page.tags") + " -- "
span= page.tag
+postTimeline(page.posts)
+postTimeline(page.posts.data)
include ./_partials/widgets/pagination.pug
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册