vuepress-theme-reco/layouts/TimeLines.vue

144 lines
3.2 KiB
Vue
Raw Normal View History

2019-04-15 10:35:40 +08:00
<template>
<div>
<Common :sidebar="false" :isComment="false">
<ul class="timeline-wrapper">
<li class="desc">Yesterday Once More!</li>
<li v-for="(item, index) in $recoPostsForTimeline" :key="index">
<h3 class="year">{{item.year}}</h3>
<ul class="year-wrapper">
<li v-for="(subItem, subIndex) in item.data" :key="subIndex">
<span class="date">{{subItem.frontmatter.date | dateFormat}}</span>
<span class="title" @click="go(subItem.path)">{{subItem.title}}</span>
</li>
</ul>
</li>
</ul>
</Common>
2019-04-15 10:35:40 +08:00
</div>
</template>
<script>
import Common from '@theme/components/Common.vue'
2019-04-15 10:35:40 +08:00
export default {
name: 'TimeLine',
components: { Common },
filters: {
2019-04-15 10:35:40 +08:00
dateFormat (date, type) {
function renderTime (date) {
const dateee = new Date(date).toJSON()
return new Date(+new Date(dateee) + 8 * 3600 * 1000).toISOString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/, '').replace(/-/g, '/')
}
date = renderTime(date)
2019-08-19 20:24:19 +08:00
const dateObj = new Date(date)
2019-04-15 10:35:40 +08:00
const mon = dateObj.getMonth() + 1
const day = dateObj.getDate()
return `${mon}-${day}`
}
},
methods: {
2019-04-15 10:35:40 +08:00
go (url) {
2019-09-20 13:54:13 +08:00
this.$router.push({ path: url })
2019-04-15 10:35:40 +08:00
}
}
}
</script>
<style src="../styles/theme.styl" lang="stylus"></style>
2019-04-15 10:35:40 +08:00
<style lang="stylus" scoped>
@require '../styles/wrapper.styl'
.timeline-wrapper
box-sizing border-box
max-width: 740px;
2019-10-27 20:34:46 +08:00
margin: 8rem auto 4rem;
2019-04-15 10:35:40 +08:00
position relative
list-style none
&::after {
content: " ";
position: absolute;
top: 14px;
left: 0;
margin-left: -2px;
width: 4px;
height: 100%;
2019-11-27 20:12:51 +08:00
background: var(--border-color);
2019-04-15 10:35:40 +08:00
}
.desc, .year {
position: relative;
color var(--text-color);
2019-04-15 10:35:40 +08:00
font-size 16px
&:before {
content: " ";
position: absolute;
z-index 2;
left: -19px;
top: 50%;
margin-left: -4px;
margin-top: -4px;
width: 8px;
height: 8px;
2019-11-27 20:12:51 +08:00
background: var(--background-color);
border: 1px solid var(--border-color);
2019-04-15 10:35:40 +08:00
border-radius: 50%;
2019-09-20 13:54:13 +08:00
}
2019-04-15 10:35:40 +08:00
}
.year {
margin: 80px 0 0px;
color var(--text-color);
2019-04-15 10:35:40 +08:00
font-weight: 700;
font-size 26px
}
.year-wrapper {
padding-left 0!important
li {
display flex
padding 30px 0 10px
list-style none
2019-11-27 20:12:51 +08:00
border-bottom: 1px dashed var(--border-color);
2019-04-15 10:35:40 +08:00
position relative
&:hover {
.date {
color $accentColor
&::before {
background $accentColor
}
2019-09-20 13:54:13 +08:00
}
2019-04-15 10:35:40 +08:00
.title {
color $accentColor
}
}
.date {
width 40px
line-height 30px
color $textColorSub
2019-04-15 10:35:40 +08:00
font-size 12px
&::before {
content: " ";
position: absolute;
left: -19px;
top: 41px;
width: 6px;
height: 6px;
margin-left: -4px;
2019-11-27 20:12:51 +08:00
background: var(--background-color);
2019-04-15 10:35:40 +08:00
border-radius: 50%;
2019-11-27 20:12:51 +08:00
border: 1px solid var(--border-color);
2019-04-15 10:35:40 +08:00
z-index 2
2019-09-20 13:54:13 +08:00
}
2019-04-15 10:35:40 +08:00
}
.title {
line-height 30px
color $textColorSub
2019-04-15 10:35:40 +08:00
font-size 16px
cursor pointer
}
}
}
@media (max-width: $MQMobile)
.timeline-wrapper
margin: 0 1.2rem;
</style>