Skip to content

Commit f17e9d5

Browse files
author
reco_luan
committed
feat: add article sign
add sticky and password icon sticky article sorted at the top of the list
1 parent 1e44507 commit f17e9d5

File tree

8 files changed

+37
-10
lines changed

8 files changed

+37
-10
lines changed

components/NoteAbstractItem.vue

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<template>
22
<div
33
class="abstract-item">
4+
<i v-if="item.frontmatter.sticky" class="iconfont reco-place-to-top"></i>
45
<div class="title">
6+
<i v-if="item.frontmatter.keys" class="iconfont reco-lock"></i>
57
<router-link :to="item.path">{{item.title}}</router-link>
68
</div>
79
<div class="abstract" v-html="item.excerpt"></div>
@@ -27,6 +29,7 @@ export default {
2729
@require '../styles/recoConfig.styl'
2830
2931
.abstract-item
32+
position relative
3033
margin: 0 auto 20px;
3134
padding: 16px 20px;
3235
width 100%
@@ -36,14 +39,26 @@ export default {
3639
box-sizing: border-box;
3740
transition all .3s
3841
background-color $bgColor
42+
.reco-place-to-top
43+
position absolute
44+
top -5px
45+
left -3px
46+
display inline-block
47+
color $accentColor
48+
font-size 2.4rem
3949
&:hover
4050
box-shadow: $boxShadowHover
4151
.title
4252
position: relative;
4353
font-size: 1.28rem;
4454
line-height: 36px;
4555
display: inline-block;
46-
:after
56+
a
57+
color $textColor
58+
.reco-lock
59+
font-size 1.28rem
60+
color $accentColor
61+
&:after
4762
content: "";
4863
position: absolute;
4964
width: 100%;
@@ -55,7 +70,9 @@ export default {
5570
-webkit-transform: scaleX(0);
5671
transform: scaleX(0);
5772
transition: .3s ease-in-out;
58-
:hover:after
73+
&:hover a
74+
color $accentColor
75+
&:hover:after
5976
visibility visible
6077
-webkit-transform: scaleX(1);
6178
transform: scaleX(1);
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
$accentColor = #424242
2-
$textColor = #232321
1+
// $accentColor = #424242
2+
// $textColor = #232321

example/docs/views/category2/2016/121501.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ tags:
55
- tag3
66
categories:
77
- category2
8+
sticky: true
89
---
910

1011
first page in category2

example/docs/views/category2/2017/092101.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ tags:
55
- tag4
66
categories:
77
- category2
8+
keys:
9+
- '1232'
810
---
911

1012
second page in category2

layouts/Category.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ export default {
5454
// 时间降序后的博客列表
5555
posts () {
5656
let posts = this.$currentCategories.pages
57-
posts = this._filterPostData(posts)
5857
this._sortPostData(posts)
58+
posts = this._filterPostData(posts)
5959
this._setPage(1)
6060
return posts
6161
},

layouts/Tag.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ export default {
4545
// 时间降序后的博客列表
4646
posts () {
4747
let posts = this.$currentTags.pages
48-
posts = this._filterPostData(posts)
4948
this._sortPostData(posts)
49+
posts = this._filterPostData(posts)
5050
this._setPage(1)
5151
return posts
52-
},
52+
}
5353
},
5454
5555
mounted () {

layouts/TimeLines.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export default {
5454
// 根据分类获取页面数据
5555
getPages (tag) {
5656
let pages = this.$site.pages
57+
// 时间轴不进行制定处理
5758
pages = this._filterPostData(pages, true)
5859
// reverse()是为了按时间最近排序排序
5960
this.pages = pages.length == 0 ? [] : pages

mixins/index.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,18 @@ export default {
77
return tagColorArr[index]
88
},
99
_filterPostData (posts, isTimeline) {
10+
const stickyArr = []
1011
posts = posts.filter(item => {
11-
const { title, frontmatter: { home, date, publish }} = item
12+
const { title, frontmatter: { home, date, publish, sticky }} = item
13+
if (sticky) {
14+
stickyArr.unshift(item)
15+
return false
16+
}
1217
return isTimeline === true
1318
? !(home == true || title == undefined || date === undefined || publish === false)
1419
: !(home == true || title == undefined || publish === false)
1520
})
16-
return posts
21+
return stickyArr.concat(posts)
1722
},
1823
_sortPostData (posts) {
1924
posts.sort((a, b) => {
@@ -37,8 +42,9 @@ export default {
3742
let posts = articles.reduce((allData, currnetData) => {
3843
return [...allData, ...currnetData.pages]
3944
}, [])
40-
posts = _filterPostData(posts)
45+
4146
_sortPostData(posts)
47+
posts = _filterPostData(posts)
4248

4349
this.$themeConfig.posts = posts
4450
resolve(posts)

0 commit comments

Comments
 (0)