Skip to content

Commit

Permalink
添加文章分享模块
Browse files Browse the repository at this point in the history
  • Loading branch information
cetr committed Jan 29, 2020
1 parent 797a3b9 commit c5e640e
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 0 deletions.
7 changes: 7 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,13 @@ post_widget:
# Show the horizon line before the text of the end.
horizon_line: true

# Article sharing
article_share:
enable: true
#Apps to share
#Optional value: qzone, qq, weibo, wechat, douban, google, facebook, twitter
application: weibo, qq, wechat, qzone, twitter

# Automatically retain article excerpt.
auto_excerpt:
enable: false
Expand Down
7 changes: 7 additions & 0 deletions layout/_partials/widgets/share.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- var article_share = theme.article_share

div.post-share-container
div.social-share-text= "分享到:"
div.social-share(data-sites=`${article_share.application}`)
link(rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/social-share.js/1.0.16/css/share.min.css")
script(src="https://cdnjs.cloudflare.com/ajax/libs/social-share.js/1.0.16/js/social-share.min.js")
3 changes: 3 additions & 0 deletions layout/post.pug
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ block content
+gallery(page)
!= page.content

if theme.article_share && theme.article_share.enable
include ./_partials/widgets/share.pug

footer.post-footer
if theme.post_widget.end_text.enable
div.post-end
Expand Down
1 change: 1 addition & 0 deletions source/css/_common/components/widgets/index.styl
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
@import './copy-button.styl';
@import './sticky-top.styl';
@import './pagination.styl';
@import './share.styl';
21 changes: 21 additions & 0 deletions source/css/_common/components/widgets/share.styl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.post-share-container {
width: 100%;
height: 40px;
margin-bottom: 25px;
}

.post-share-container > div {
height: 40px;
float: left;
line-height: 40px;
}

.post-share-container .social-share-text {
margin-right: 4px;
font-size: 16px;
}

.post-share-container .social-share > a {
margin: 0;
margin-right: 8px;
}

0 comments on commit c5e640e

Please sign in to comment.