Skip to content

Commit 1215e56

Browse files
author
reco_luan
committed
feat(vuepress-theme-reco): add social links
ISSUES CLOSED: #252
1 parent 90e9fdc commit 1215e56

File tree

3 files changed

+61
-2
lines changed

3 files changed

+61
-2
lines changed

example/.vuepress/config.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,11 @@ module.exports = {
5050
tag: {
5151
location: 3, // 在导航栏菜单中所占的位置,默认3
5252
text: 'Tag' // 默认 “标签”
53-
}
53+
},
54+
socialLinks: [
55+
{ icon: 'reco-github', link: 'https://github.com/recoluan' },
56+
{ icon: 'reco-npm', link: 'https://www.npmjs.com/~reco_luan' }
57+
]
5458
},
5559
logo: '/head.png',
5660
authorAvatar: '/head.png',

packages/@vuepress-reco/core/src/components/RecoIcon.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ const RecoIconProps = Vue.extend({
88
icon: {
99
type: String,
1010
default: ''
11+
},
12+
link: {
13+
type: String,
14+
default: ''
1115
}
1216
}
1317
})
@@ -22,9 +26,18 @@ class RecoIcon extends RecoIconProps {
2226
}
2327
return ''
2428
}
29+
30+
go (link) {
31+
if (link === '') return
32+
window.open(link)
33+
}
34+
2535
render () {
2636
return (
27-
<i class={this.getClass(this.icon)}>
37+
<i {...{
38+
class: this.getClass(this.icon),
39+
on: { click: this.go.bind(this, this.link) }
40+
}}>
2841
{this.$slots.default}
2942
</i>
3043
)

packages/vuepress-theme-reco/components/PersonalInfo.vue

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,36 @@
2222
<h6>{{homeBlogCfg.tag}}</h6>
2323
</div>
2424
</div>
25+
<ul class="social-links">
26+
<li
27+
class="social-item"
28+
v-for="(item, index) in socialLinks"
29+
:key="index"
30+
>
31+
<reco-icon :icon="item.icon" :link="item.link" :style="{ color: item.color }" />
32+
</li>
33+
</ul>
2534
<hr>
2635
</div>
2736
</template>
2837

2938
<script>
39+
import { RecoIcon } from '@vuepress-reco/core/lib/components'
40+
import { getOneColor } from '@theme/helpers/other'
41+
3042
export default {
43+
components: { RecoIcon },
3144
computed: {
3245
homeBlogCfg () {
3346
return this.$recoLocales.homeBlog
47+
},
48+
socialLinks () {
49+
return this.$themeConfig.blogConfig.socialLinks.map(item => {
50+
if (!item.color) {
51+
item.color = getOneColor()
52+
}
53+
return item
54+
})
3455
}
3556
}
3657
}
@@ -72,5 +93,26 @@ export default {
7293
}
7394
}
7495
}
96+
.social-links {
97+
box-sizing border-box
98+
display flex
99+
flex-wrap wrap
100+
padding 10px
101+
.social-item {
102+
width 39px
103+
height 36px
104+
line-height 36px
105+
text-align center
106+
list-style none
107+
transition transform .3s
108+
&:hover {
109+
transform scale(1.08)
110+
}
111+
.iconfont {
112+
cursor pointer
113+
font-size 22px
114+
}
115+
}
116+
}
75117
}
76118
</style>

0 commit comments

Comments
 (0)