Skip to content

Commit 8e6616b

Browse files
author
reco_luan
committed
feat: add FriendLink
1 parent fbff8a2 commit 8e6616b

File tree

3 files changed

+63
-15
lines changed

3 files changed

+63
-15
lines changed

components/FriendLink.vue

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<template>
2+
<div class="friend-link-wrapper">
3+
<a
4+
v-for="(item, index) in $themeConfig.friendLink"
5+
:key="index"
6+
:href="item.link"
7+
target="_blank">
8+
<span
9+
class="list-style"
10+
:style="{ 'backgroundColor': _tagColor() }">
11+
</span>
12+
{{item.title}}
13+
</a>
14+
</div>
15+
</template>
16+
17+
<script>
18+
import mixin from '@theme/mixins/index.js'
19+
20+
export default {
21+
mixins: [mixin]
22+
}
23+
</script>
24+
25+
<style lang="stylus" scoped>
26+
@require '../styles/recoConfig.styl'
27+
28+
.friend-link-wrapper
29+
margin 30px 0
30+
> a
31+
position relative
32+
vertical-align: middle;
33+
margin: 4px 4px 10px;
34+
padding: 4px 8px 4px 20px;
35+
display: inline-block;
36+
cursor: pointer;
37+
border-radius: $borderRadius
38+
background: #fff;
39+
font-size: 13px;
40+
box-shadow $boxShadow
41+
transition: all .5s
42+
.list-style
43+
position absolute
44+
left .4rem
45+
top 0
46+
bottom 0
47+
margin auto
48+
display block
49+
width .4rem
50+
height .4rem
51+
border-radius .1rem
52+
background $accentColor
53+
content ''
54+
&:hover
55+
transform scale(1.04)
56+
</style>

components/HomeBlog.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@
4646
</ul>
4747
<hr>
4848
<h4 v-if="$tags.list.length !== 0"><i class="iconfont reco-tag"></i> 标签</h4>
49-
<TagList @getCurrentTag="getPagesByTags"></TagList>
49+
<TagList @getCurrentTag="getPagesByTags" />
50+
<h4 v-if="$themeConfig.friendLink && $themeConfig.friendLink.length !== 0"><i class="iconfont reco-tag"></i> 友链</h4>
51+
<FriendLink />
5052
</div>
5153
</div>
5254

@@ -56,12 +58,13 @@
5658

5759
<script>
5860
import TagList from '@theme/components/TagList.vue'
61+
import FriendLink from '@theme/components/FriendLink.vue'
5962
import NoteAbstract from '@theme/components/NoteAbstract.vue'
6063
import mixin from '@theme/mixins/index.js'
6164
6265
export default {
6366
mixins: [mixin],
64-
components: { NoteAbstract, TagList },
67+
components: { NoteAbstract, TagList, FriendLink },
6568
data () {
6669
return {
6770
recoShow: false,

components/TagList.vue

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<template>
22
<div class="tags">
33
<span
4-
v-for="(item, index) in tags"
4+
v-for="(item, index) in $tags.list"
55
:key="index"
66
:class="{'active': item.name == currentTag}"
7-
:style="{ 'backgroundColor': item.color }"
7+
:style="{ 'backgroundColor': _tagColor() }"
88
@click="tagClick(item.name)">{{item.name}}</span>
99
</div>
1010
</template>
@@ -25,17 +25,6 @@ export default {
2525
tags: []
2626
}
2727
},
28-
created () {
29-
if (this.$tags.list.length > 0) {
30-
const tags = this.$tags.list
31-
tags.map(item => {
32-
const color = this._tagColor()
33-
item.color = color
34-
return tags
35-
})
36-
this.tags = [{ name: '全部', color: this._tagColor() }, ...tags]
37-
}
38-
},
3928
methods: {
4029
tagClick (tag) {
4130
this.$emit('getCurrentTag', tag)

0 commit comments

Comments
 (0)