forked from vuepress/vuepress-theme-blog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBaseListLayout.vue
208 lines (174 loc) · 4.39 KB
/
BaseListLayout.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
<template>
<div id="base-list-layout">
<div class="ui-posts" itemscope itemtype="http://schema.org/Blog">
<article
v-for="page in pages"
:key="page.key"
class="ui-post"
itemprop="blogPost"
itemscope
itemtype="https://schema.org/BlogPosting"
>
<meta itemprop="mainEntityOfPage" :content="page.path" />
<meta
v-if="page.lastUpdated"
itemprop="dateModified"
:content="page.lastUpdated"
/>
<header class="ui-post-title" itemprop="name headline">
<NavLink :link="page.path">{{ page.title }}</NavLink>
</header>
<p class="ui-post-summary" itemprop="description">
{{ page.frontmatter.summary || page.summary }}
<!-- <Content :page-key="page.key" slot-key="intro"/>-->
</p>
<footer>
<div
v-if="page.frontmatter.author"
class="ui-post-meta ui-post-author"
>
<NavigationIcon />
<span itemprop="author">{{ page.frontmatter.author }}</span>
<span v-if="page.frontmatter.location">
in {{ page.frontmatter.location }}
</span>
</div>
<div v-if="page.frontmatter.date" class="ui-post-meta ui-post-date">
<ClockIcon />
<time
pubdate
itemprop="datePublished"
:datetime="page.frontmatter.date"
>
{{ resolvePostDate(page.frontmatter.date) }}
</time>
</div>
<div
v-if="page.frontmatter.tags"
class="ui-post-meta ui-post-tag"
itemprop="keywords"
>
<TagIcon />
<router-link
v-for="tag in resolvePostTags(page.frontmatter.tags)"
:key="tag"
:to="'/tag/' + tag"
>
{{ tag }}
</router-link>
</div>
</footer>
</article>
</div>
<component
:is="paginationComponent"
v-if="$pagination.length > 1 && paginationComponent"
></component>
</div>
</template>
<script>
/* global THEME_BLOG_PAGINATION_COMPONENT */
import Vue from 'vue'
import dayjs from 'dayjs'
import { NavigationIcon, ClockIcon, TagIcon } from 'vue-feather-icons'
import {
Pagination,
SimplePagination,
} from '@vuepress/plugin-blog/lib/client/components'
export default {
components: { NavigationIcon, ClockIcon, TagIcon },
data() {
return {
paginationComponent: null,
}
},
computed: {
pages() {
return this.$pagination.pages
},
},
created() {
this.paginationComponent = this.getPaginationComponent()
},
methods: {
getPaginationComponent() {
const n = THEME_BLOG_PAGINATION_COMPONENT
if (n === 'Pagination') {
return Pagination
}
if (n === 'SimplePagination') {
return SimplePagination
}
return Vue.component(n) || Pagination
},
resolvePostDate(date) {
return dayjs(date).format(
this.$themeConfig.dateFormat || 'ddd MMM DD YYYY'
)
},
resolvePostTags(tags) {
if (!tags || Array.isArray(tags)) return tags
return [tags]
},
},
}
</script>
<style lang="stylus">
.common-layout
.content-wrapper
padding-bottom 80px
.ui-post
padding-bottom 25px
margin-bottom 25px
border-bottom 1px solid $borderColor
&:last-child
border-bottom 0px
margin-bottom 0px
.ui-post-title
font-family PT Serif, Serif
font-size 28px
border-bottom 0
a
cursor pointer
color $darkTextColor
transition all 0.2s
text-decoration none
&:hover
text-decoration underline
.ui-post-summary
font-size 14px
color rgba($darkTextColor, 0.54)
font-weight 200
.ui-post-meta
display inline-flex
align-items center
font-size 12px
line-height 12px
&:not(:last-child)
margin-bottom 3px
margin-right 20px
svg
margin-right 5px
width 14px
height 14px
@media (max-width: $MQMobile)
display flex
&:not(:last-child)
margin-bottom 10px
.ui-post-author
color rgba($darkTextColor, 0.84)
font-weight 400
.ui-post-date
color rgba($darkTextColor, 0.54)
font-weight 200
.ui-post-tag
color rgba($darkTextColor, 0.54)
font-weight 200
a
color inherit
font-weight 200
text-decoration none
margin-right 5px
&:hover
color $accentColor
</style>