Skip to content

Commit 30bad0d

Browse files
committed
🎨 update archives and fix bug
1 parent ed7ab11 commit 30bad0d

File tree

6 files changed

+136
-7
lines changed

6 files changed

+136
-7
lines changed

docs/.vuepress/nav/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ module.exports = [
5555
text: 'Project',
5656
link: '/project/'
5757
},
58+
{
59+
text: 'Archives',
60+
link: '/archives/',
61+
},
5862
{
5963
text: 'Resume',
6064
link: '/about/'
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<template>
2+
</template>
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
<template>
2+
<div class="archives-content" style="margin-top: 50px">
3+
<div class="block" >
4+
<el-timeline>
5+
<el-timeline-item timestamp="2018/4/12" placement="top" icon="el-icon-loading">
6+
<el-card>
7+
<h4>更新 Github 模板</h4>
8+
<p>王小虎 提交于 2018/4/12 20:46</p>
9+
</el-card>
10+
</el-timeline-item>
11+
12+
</el-timeline>
13+
</div>
14+
</div>
15+
</template>
16+
17+
<script>
18+
export default {
19+
name: "Archives",
20+
props: {
21+
pages: {
22+
type: Array,
23+
default: []
24+
}
25+
},
26+
data() {
27+
return {
28+
selectedTags: []
29+
};
30+
},
31+
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+
}
61+
}
62+
},
63+
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;
88+
});
89+
}
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+
}
110+
}
111+
};
112+
console.log("sss");
113+
</script>
114+
<style>
115+
.el-timeline-item__content > .el-card > .el-card__body {
116+
text-align: left;
117+
}
118+
</style>
119+
120+
121+

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export default {
5151
background-repeat: no-repeat;
5252
background-size: cover;
5353
background-attachment: fixed;
54-
margin-top: 150px;
54+
margin-top: 120px;
5555
}
5656
.nickname span {
5757
font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB",
@@ -86,7 +86,7 @@ export default {
8686
}
8787
}
8888
89-
@media (max-width: 1020px) {
89+
@media (max-width: 1200px) {
9090
.box-card {
9191
width: 100%;
9292
}
@@ -133,10 +133,7 @@ export default {
133133
}
134134
</style>
135135
<style>
136-
.el-card__body {
137-
display: flex;
138-
flex-direction: column;
139-
align-items: center;
140-
justify-content: center;
136+
.cardpage>.el-card >.el-card__body {
137+
display: flex; flex-direction: column; align-items: center; justify-content: center;
141138
}
142139
</style>

docs/.vuepress/theme/styles/theme.styl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ body
5555

5656
.content:not(.custom)
5757
@extend $wrapper
58+
> *:first-child
59+
margin-top $navbarHeight
5860
a:hover
5961
text-decoration underline
6062
p.demo

docs/archives/README.md

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

0 commit comments

Comments
 (0)