1
1
<template >
2
2
<div class =" archives-content" style =" margin-top : 50px " >
3
3
<div class =" block" >
4
- <el-timeline >
5
- <el-timeline-item v-for =" item in ArchivesArray" :timestamp =" item.frontmatter.date" placement =" top" icon =" el-icon-loading" >
4
+ <el-timeline :reverse =" true" >
5
+ <el-timeline-item
6
+ v-for =" item in ArchivesArray"
7
+ :timestamp =" item.frontmatter.dateTime"
8
+ placement =" top"
9
+ icon =" el-icon-loading"
10
+ >
6
11
<el-card >
7
- <p class =" article-title" ><router-link :to =" item.regularPath" >{{ item.frontmatter.title}}</router-link ></p >
12
+ <p class =" article-title" >
13
+ <router-link :to =" item.regularPath" >{{ item.frontmatter.title}}</router-link >
14
+ </p >
8
15
<p >Finen于{{ item.frontmatter.date}}发布该文章</p >
9
16
<!-- <el-tag>原创</el-tag><br/> -->
10
17
<div class =" archives-tag" >
11
- <p class =" article-tag" >Tags: <el-tag v-for =" tag in item.frontmatter.tags" >{{tag}}</el-tag ></p >
18
+ <p class =" article-tag" >
19
+ Tags:
20
+ <el-tag v-for =" tag in item.frontmatter.tags" >{{tag}}</el-tag >
21
+ </p >
12
22
</div >
13
23
</el-card >
14
24
</el-timeline-item >
@@ -26,53 +36,73 @@ export default {
26
36
default: []
27
37
}
28
38
},
29
- data () {
39
+ data () {
30
40
return {
31
41
ArchivesArray: []
32
- }
42
+ };
33
43
},
34
- mounted : function () {
35
- this .filterListFun ()
44
+ mounted : function () {
45
+ this .filterArchivesList ();
36
46
},
37
47
computed: {
38
48
// 用于刷选frontmatter中有post: true的数据
39
- filterList () {
40
-
41
- }
49
+ filterList () {}
42
50
43
51
// 将筛选出来的数据进行时间排序
44
52
},
45
53
methods: {
46
- filterListFun () {
54
+ filterArchivesList () {
47
55
this .pages .forEach (element => {
48
- if (element .frontmatter .post == true ){
56
+ if (element .frontmatter .post == true ) {
57
+ element .frontmatter .dateTime = this .formatDate (element .frontmatter .date );
58
+ element .ArticleDate = this .formatDate (element .frontmatter .date );
49
59
this .ArchivesArray .push (element);
50
60
}
51
61
});
52
- }
62
+ // 通过时间进行排序
63
+ this .ArchivesArray .sort (this .compare (" ArticleDate" ));
64
+ },
65
+ formatDate (time ) {
66
+ var dateTime = new Date (new Date (time).getTime ());
67
+ var y = dateTime .getFullYear ();
68
+ var month = dateTime .getMonth () + 1 ;
69
+ var m = month < 10 ? " 0" + month : month;
70
+ var d = dateTime .getDate () < 10 ? " 0" + dateTime .getDate () : dateTime .getDate ();
71
+ var sendDate = y + " -" + m + " -" + d;
72
+ return sendDate;
73
+ },
74
+ compare (pro ) {
75
+ return function (obj1 , obj2 ) {
76
+ var val1 = obj1[pro];
77
+ var val2 = obj2[pro];
78
+ if (val1 < val2 ) { // 正序
79
+ return 1 ;
80
+ } else if (val1 > val2 ) {
81
+ return - 1 ;
82
+ } else {
83
+ return 0 ;
84
+ }
85
+ }
86
+ }
53
87
}
54
- }
88
+ };
55
89
</script >
56
90
<style >
57
91
.el-timeline-item__content > .el-card > .el-card__body {
58
92
text-align : left ;
59
93
}
60
- .el-card > .el-card__body > .article-title {
94
+ .el-card > .el-card__body > .article-title {
61
95
font-size : 20px ;
62
96
font-weight : 600 ;
63
97
font-family : " Helvetica Neue" , Helvetica , " PingFang SC" , " Hiragino Sans GB" ,
64
- " Microsoft YaHei" , " 微软雅黑" , Arial , sans-serif ;
98
+ " Microsoft YaHei" , " 微软雅黑" , Arial , sans-serif ;
65
99
}
66
- .archives-tag > .article-tag {
67
- font-size : 16px ;
68
- font-weight : 500 ;
100
+ .archives-tag > .article-tag {
101
+ font-size : 14px ;
69
102
font-family : " Helvetica Neue" , Helvetica , " PingFang SC" , " Hiragino Sans GB" ,
70
- " Microsoft YaHei" , " 微软雅黑" , Arial , sans-serif ;
103
+ " Microsoft YaHei" , " 微软雅黑" , Arial , sans-serif ;
71
104
}
72
- .archives-tag > .article-tag > .el-tag {
105
+ .archives-tag > .article-tag > .el-tag {
73
106
margin-left : 5px ;
74
107
}
75
108
</style >
76
-
77
-
78
-
0 commit comments