vuepress-theme-reco/components/PageInfo.vue

87 lines
1.8 KiB
Vue
Raw Normal View History

2019-04-15 10:35:40 +08:00
<template>
<div>
<i
class="iconfont reco-account"
2019-05-08 15:13:18 +08:00
v-if="pageInfo.frontmatter.author || $themeConfig.author || $site.title">
<span>{{ pageInfo.frontmatter.author || $themeConfig.author || $site.title }}</span>
2019-04-15 10:35:40 +08:00
</i>
<i class="iconfont reco-date" v-if="pageInfo.frontmatter.date"><span>{{ new Date(pageInfo.frontmatter.date).toLocaleDateString() }}</span></i>
2019-07-20 19:38:25 +08:00
<AccessNumber v-if="isHome !== true" :idVal="pageInfo.path" :numStyle="numStyle"></AccessNumber>
2019-04-15 10:35:40 +08:00
<i class="iconfont reco-tag tags" v-if="pageInfo.frontmatter.tags">
<span
v-for="(subItem, subIndex) in pageInfo.frontmatter.tags"
:key="subIndex"
class="tag-item"
:class="{ 'active': currentTag == subItem }"
@click="goTags(subItem)">
{{subItem}}
</span>
</i>
</div>
</template>
<script>
import AccessNumber from './Valine/AccessNumber'
export default {
components: { AccessNumber },
2019-07-20 19:38:25 +08:00
// props: ['pageInfo', 'currentTag'],
props: {
pageInfo: {
type: Object,
default: {}
},
currentTag: {
type: String,
default: ''
},
isHome: {
type: Boolean,
default: false
}
},
2019-04-15 10:35:40 +08:00
data () {
return {
numStyle: {
fontSize: '.9rem',
fontWeight: 'normal',
color: '#999'
}
}
},
2019-07-20 19:38:25 +08:00
mounted () {
console.log(1234, this.isHome)
},
2019-04-15 10:35:40 +08:00
methods: {
goTags (tag) {
2019-07-20 19:38:25 +08:00
window.location.href = `/tag/#?tag=${tag}`
2019-04-15 10:35:40 +08:00
}
}
}
</script>
<style lang="stylus" scoped>
.iconfont
display inline-block
line-height 1.5rem
&:not(:last-child)
margin-right 1rem
span
margin-left .5rem
.tags
.tag-item
cursor: pointer;
&.active
color $accentColor
&:hover
color $accentColor
@media (max-width: $MQMobile)
.tags
display block
margin-left: 0!important;
</style>