Skip to content

Commit 7d12546

Browse files
committed
:octocat: add Archives page
1 parent 30bad0d commit 7d12546

File tree

4 files changed

+56
-83
lines changed

4 files changed

+56
-83
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222

2323
> 如果您想用该项目部署您自己的blog,请fork本项目,然后clone到您本地即可更改。如果您懂vue.js,那您可以自己开发一部分插件。
2424
25+
## 功能
26+
- [x] Archives
27+
- [ ] Tags Cloud
28+
- [ ] Cate
29+
2530
## 评论功能
2631

2732
### 评论工具1 Valine.js

docs/.vuepress/theme/global-components/Archives.vue

Lines changed: 40 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
<template>
22
<div class="archives-content" style="margin-top: 50px">
3-
<div class="block" >
3+
<div class="block">
44
<el-timeline>
5-
<el-timeline-item timestamp="2018/4/12" placement="top" icon="el-icon-loading">
5+
<el-timeline-item v-for="item in ArchivesArray" :timestamp="item.frontmatter.date" placement="top" icon="el-icon-loading">
66
<el-card>
7-
<h4>更新 Github 模板</h4>
8-
<p>王小虎 提交于 2018/4/12 20:46</p>
7+
<p class="article-title"><router-link :to="item.regularPath">{{ item.frontmatter.title}}</router-link></p>
8+
<p>Finen于{{ item.frontmatter.date}}发布该文章</p>
9+
<!-- <el-tag>原创</el-tag><br/> -->
10+
<div class="archives-tag">
11+
<p class="article-tag">Tags: <el-tag v-for="tag in item.frontmatter.tags">{{tag}}</el-tag></p>
12+
</div>
913
</el-card>
1014
</el-timeline-item>
11-
1215
</el-timeline>
1316
</div>
1417
</div>
@@ -23,98 +26,52 @@ export default {
2326
default: []
2427
}
2528
},
26-
data() {
29+
data () {
2730
return {
28-
selectedTags: []
29-
};
31+
ArchivesArray: []
32+
}
33+
},
34+
mounted: function () {
35+
this.filterListFun()
3036
},
3137
computed: {
32-
filteredList() {
33-
if (this.pages) {
34-
return this.pages
35-
.filter(item => {
36-
const isBlogPost = !!item.frontmatter.blog;
37-
const isReadyToPublish =
38-
new Date(item.frontmatter.date) <= new Date();
39-
// check if tags contain any of the selected tags
40-
// const hasTags = item.frontmatter.tags && item.frontmatter.tags.some(tag => this.selectedTags.includes(tag))
41-
// check if tags contain all of the selected tags
42-
const hasTags =
43-
!!item.frontmatter.tags &&
44-
this.selectedTags.every(tag =>
45-
item.frontmatter.tags.includes(tag)
46-
);
47-
if (
48-
!isBlogPost ||
49-
!isReadyToPublish ||
50-
(this.selectedTags.length > 0 && !hasTags)
51-
) {
52-
return false;
53-
}
54-
return true;
55-
})
56-
.sort(
57-
(a, b) =>
58-
new Date(b.frontmatter.date) - new Date(a.frontmatter.date)
59-
);
60-
}
38+
// 用于刷选frontmatter中有post: true的数据
39+
filterList () {
40+
6141
}
42+
43+
//将筛选出来的数据进行时间排序
6244
},
6345
methods: {
64-
getYears: function() {
65-
return [
66-
...new Set(
67-
this.filteredList.map(item =>
68-
new Date(item.frontmatter.date).getFullYear()
69-
)
70-
)
71-
];
72-
},
73-
getMonths: function(year) {
74-
return [
75-
...new Set(
76-
this.filteredList
77-
.filter(
78-
item => new Date(item.frontmatter.date).getFullYear() == year
79-
)
80-
.map(item => new Date(item.frontmatter.date).getMonth())
81-
)
82-
];
83-
},
84-
postsByDate(year, month) {
85-
return this.filteredList.filter(item => {
86-
const date = new Date(item.frontmatter.date);
87-
return date.getFullYear() == year && date.getMonth() == month;
46+
filterListFun () {
47+
this.pages.forEach(element => {
48+
if(element.frontmatter.post==true){
49+
this.ArchivesArray.push(element);
50+
}
8851
});
8952
}
90-
},
91-
filters: {
92-
// Filter definitions
93-
monthToLongName(value) {
94-
const months = [
95-
"January",
96-
"February",
97-
"March",
98-
"April",
99-
"May",
100-
"June",
101-
"July",
102-
"August",
103-
"September",
104-
"October",
105-
"November",
106-
"December"
107-
];
108-
return months[value];
109-
}
11053
}
111-
};
112-
console.log("sss");
54+
}
11355
</script>
11456
<style>
11557
.el-timeline-item__content > .el-card > .el-card__body {
11658
text-align: left;
11759
}
60+
.el-card>.el-card__body>.article-title{
61+
font-size: 20px;
62+
font-weight: 600;
63+
font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB",
64+
"Microsoft YaHei", "微软雅黑", Arial, sans-serif;
65+
}
66+
.archives-tag>.article-tag{
67+
font-size: 16px;
68+
font-weight: 500;
69+
font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB",
70+
"Microsoft YaHei", "微软雅黑", Arial, sans-serif;
71+
}
72+
.archives-tag>.article-tag>.el-tag{
73+
margin-left: 5px;
74+
}
11875
</style>
11976

12077

docs/archives/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
11
---
22
---
33
<Archives :pages="$site.pages"/>
4+
<!-- {{$site.pages}} -->
5+
6+
<!-- <div v-for="item in $site.pages">
7+
<div v-if="item.frontmatter.post == true">
8+
<!-- {{ item.frontmatter }}
9+
{{ item.frontmatter.title}}
10+
{{ item.frontmatter.date}}
11+
{{ item.regularPath }}
12+
</div>
13+
</div> -->

docs/blog/Java/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ title: Java百度翻译API
33
copyright: true
44
date: 2018-03-28 22:57:32
55
comments: true
6+
post: true
67
categories:
78
- Java
89
tags:

0 commit comments

Comments
 (0)