forked from vuepress/vuepress-theme-blog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPostMeta.vue
79 lines (73 loc) · 1.58 KB
/
PostMeta.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<template>
<div class="post-meta">
<div v-if="author" class="post-meta-author">
<NavigationIcon />
<span itemprop="author">{{ author }}</span>
<span v-if="location"> in {{ location }}</span>
</div>
<div v-if="date" class="post-meta-date">
<ClockIcon />
<time pubdate itemprop="datePublished" :datetime="date">
{{ resolvedDate }}
</time>
</div>
<ul v-if="tags" class="post-meta-tags" itemprop="keywords">
<PostTag v-for="tag in resolvedTags" :key="tag" :tag="tag" />
</ul>
</div>
</template>
<script>
import dayjs from 'dayjs'
import { NavigationIcon, ClockIcon } from 'vue-feather-icons'
import PostTag from './PostTag.vue'
export default {
name: 'PostMeta',
components: { NavigationIcon, ClockIcon, PostTag },
props: {
tags: {
type: [Array, String],
},
author: {
type: String,
},
date: {
type: String,
},
location: {
type: String,
},
},
computed: {
resolvedDate() {
return dayjs(this.date).format(
this.$themeConfig.dateFormat || 'ddd MMM DD YYYY'
)
},
resolvedTags() {
if (!this.tags || Array.isArray(this.tags)) return this.tags
return [this.tags]
},
},
}
</script>
<style lang="stylus">
.post-meta
&-tags
display flex
flex-wrap wrap
list-style none
overflow hidden
padding 0
margin 20px 0
> li
margin-bottom 10px
> div
display inline-flex
line-height 12px
font-size 12px
margin-right 20px
svg
margin-right 5px
width 14px
height 14px
</style>