Skip to content

Commit 025a4f6

Browse files
committed
🎨 add tags cloud
1 parent 7d12546 commit 025a4f6

File tree

4 files changed

+122
-34
lines changed

4 files changed

+122
-34
lines changed

docs/.vuepress/nav/index.js

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,28 @@ module.exports = [
4545
]
4646
},
4747
{
48-
text: 'Tools Sharing',
49-
items: [
50-
{ text: 'Book Sharing', link: '/share/book/' },
51-
{ text: 'Software Sharing', link: '/share/software/' }
52-
]
48+
text: 'Archives',
49+
link: '/archives/',
5350
},
5451
{
55-
text: 'Project',
56-
link: '/project/'
52+
text: 'Tags',
53+
link: '/tags/',
5754
},
5855
{
59-
text: 'Archives',
60-
link: '/archives/',
56+
text: 'Another',
57+
items: [
58+
{
59+
text: 'Project',
60+
link: '/project/'
61+
},
62+
{
63+
text: 'Tools Sharing',
64+
items: [
65+
{ text: 'Book Sharing', link: '/share/book/' },
66+
{ text: 'Software Sharing', link: '/share/software/' }
67+
]
68+
},
69+
],
6170
},
6271
{
6372
text: 'Resume',

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

Lines changed: 55 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
11
<template>
22
<div class="archives-content" style="margin-top: 50px">
33
<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+
>
611
<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>
815
<p>Finen于{{ item.frontmatter.date}}发布该文章</p>
916
<!-- <el-tag>原创</el-tag><br/> -->
1017
<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>
1222
</div>
1323
</el-card>
1424
</el-timeline-item>
@@ -26,53 +36,73 @@ export default {
2636
default: []
2737
}
2838
},
29-
data () {
39+
data() {
3040
return {
3141
ArchivesArray: []
32-
}
42+
};
3343
},
34-
mounted: function () {
35-
this.filterListFun()
44+
mounted: function() {
45+
this.filterArchivesList();
3646
},
3747
computed: {
3848
// 用于刷选frontmatter中有post: true的数据
39-
filterList () {
40-
41-
}
49+
filterList() {}
4250
4351
//将筛选出来的数据进行时间排序
4452
},
4553
methods: {
46-
filterListFun () {
54+
filterArchivesList() {
4755
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);
4959
this.ArchivesArray.push(element);
5060
}
5161
});
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+
}
5387
}
54-
}
88+
};
5589
</script>
5690
<style>
5791
.el-timeline-item__content > .el-card > .el-card__body {
5892
text-align: left;
5993
}
60-
.el-card>.el-card__body>.article-title{
94+
.el-card > .el-card__body > .article-title {
6195
font-size: 20px;
6296
font-weight: 600;
6397
font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB",
64-
"Microsoft YaHei", "微软雅黑", Arial, sans-serif;
98+
"Microsoft YaHei", "微软雅黑", Arial, sans-serif;
6599
}
66-
.archives-tag>.article-tag{
67-
font-size: 16px;
68-
font-weight: 500;
100+
.archives-tag > .article-tag {
101+
font-size: 14px;
69102
font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB",
70-
"Microsoft YaHei", "微软雅黑", Arial, sans-serif;
103+
"Microsoft YaHei", "微软雅黑", Arial, sans-serif;
71104
}
72-
.archives-tag>.article-tag>.el-tag{
105+
.archives-tag > .article-tag > .el-tag {
73106
margin-left: 5px;
74107
}
75108
</style>
76-
77-
78-
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<template>
2+
<div class="tag-content">
3+
<div class="tags-cloud">
4+
<el-badge :value="5" class="item" >
5+
<el-button size="small">git</el-button>
6+
</el-badge>
7+
</div>
8+
</div>
9+
</template>
10+
11+
<script>
12+
export default {
13+
name: "TagsCloud",
14+
props: {
15+
pages: {
16+
type: Array,
17+
default: []
18+
}
19+
},
20+
data() {
21+
return {
22+
TagsArray: [],
23+
tagsCloud: []
24+
};
25+
},
26+
mounted: function() {
27+
this.filterTagsList();
28+
},
29+
methods: {
30+
filterTagsList() {
31+
this.pages.forEach(element => {
32+
if (element.frontmatter.post == true) {
33+
this.TagsArray.push(element);
34+
element.tags = element.frontmatter.tags;
35+
element.frontmatter.tags.forEach(item => {
36+
this.tagsCloud.push(item);
37+
});
38+
}
39+
});
40+
console.log(this.tagsCloud);
41+
console.log(this.tagsCloud.length);
42+
}
43+
}
44+
};
45+
</script>

docs/tags/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
---
3+
## Tags Cloud
4+
<TagsCloud :pages="$site.pages"/>

0 commit comments

Comments
 (0)