mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-12 22:17:06 +08:00
✨ 增加facebook comments
This commit is contained in:
13
_config.yml
13
_config.yml
@@ -280,6 +280,17 @@ utterances:
|
|||||||
light_theme: github-light
|
light_theme: github-light
|
||||||
dark_theme: photon-dark
|
dark_theme: photon-dark
|
||||||
|
|
||||||
|
# Facebook Comments Plugin
|
||||||
|
# https://developers.facebook.com/docs/plugins/comments/
|
||||||
|
facebook_comments:
|
||||||
|
enable: false
|
||||||
|
app_id:
|
||||||
|
user_id: # optional
|
||||||
|
pageSize: 10 # The number of comments to show
|
||||||
|
order_by: social # social/time/reverse_time
|
||||||
|
lang: en_US # Language en_US/zh_CN/zh_TW and so on
|
||||||
|
count: true
|
||||||
|
|
||||||
##### Footer Settings ####
|
##### Footer Settings ####
|
||||||
# ------------------------------------
|
# ------------------------------------
|
||||||
since: 2020
|
since: 2020
|
||||||
@@ -670,7 +681,7 @@ fragment_cache: true
|
|||||||
# 插入代码到头部</head>之前 和 尾部</body>之前
|
# 插入代码到头部</head>之前 和 尾部</body>之前
|
||||||
inject:
|
inject:
|
||||||
head:
|
head:
|
||||||
# - <link rel="stylesheet" href="xxxxx">
|
# - <link rel="stylesheet" href="xxxxx">
|
||||||
bottom:
|
bottom:
|
||||||
# - <script src="xxxx"></script>
|
# - <script src="xxxx"></script>
|
||||||
|
|
||||||
|
|||||||
12
layout/includes/comments/facebook_comments.pug
Normal file
12
layout/includes/comments/facebook_comments.pug
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
#fb-root
|
||||||
|
script(async defer crossorigin="anonymous" src=`https://connect.facebook.net/${theme.facebook_comments.lang}/sdk.js#xfbml=1&version=v6.0`)
|
||||||
|
.fb-comments(data-colorscheme = theme.display_mode === 'dark' ? 'dark' : 'light'
|
||||||
|
data-href=urlNoIndex()
|
||||||
|
data-numposts= theme.facebook_comments.pageSize || 10
|
||||||
|
data-order-by= theme.facebook_comments.order_by || 'social'
|
||||||
|
data-width="100%")
|
||||||
|
|
||||||
|
if theme.darkmode.enable
|
||||||
|
script.
|
||||||
|
var themeNow = document.documentElement.getAttribute('data-theme') === 'dark' ? 'dark' : 'light'
|
||||||
|
document.getElementsByClassName('fb-comments')[0].setAttribute('data-colorscheme',themeNow)
|
||||||
@@ -4,7 +4,8 @@
|
|||||||
- var gt = theme.gitalk && theme.gitalk.enable
|
- var gt = theme.gitalk && theme.gitalk.enable
|
||||||
- var v = theme.valine && theme.valine.enable
|
- var v = theme.valine && theme.valine.enable
|
||||||
- var u = theme.utterances && theme.utterances.enable
|
- var u = theme.utterances && theme.utterances.enable
|
||||||
- var isComment = d || dj || l || gt || v || u
|
- var fb = theme.facebook_comments && theme.facebook_comments.enable
|
||||||
|
- var isComment = d || dj || l || gt || v || u || fb
|
||||||
|
|
||||||
if isComment
|
if isComment
|
||||||
hr
|
hr
|
||||||
@@ -24,3 +25,5 @@ if isComment
|
|||||||
include ./valine.pug
|
include ./valine.pug
|
||||||
else if u
|
else if u
|
||||||
include ./utterances.pug
|
include ./utterances.pug
|
||||||
|
else if fb
|
||||||
|
include ./facebook_comments.pug
|
||||||
@@ -17,7 +17,6 @@
|
|||||||
- else pageKeywords = Array.isArray(config.keywords) ? (config.keywords).join(','): ([]).join(',') || config.keywords
|
- else pageKeywords = Array.isArray(config.keywords) ? (config.keywords).join(','): ([]).join(',') || config.keywords
|
||||||
- var pageAuthor = config.email ? config.author + ',' + config.email : config.author
|
- var pageAuthor = config.email ? config.author + ',' + config.email : config.author
|
||||||
- var pageCopyright = config.copyright || config.author
|
- var pageCopyright = config.copyright || config.author
|
||||||
- var without_html = url.replace('index.html', '')
|
|
||||||
|
|
||||||
meta(charset='UTF-8')
|
meta(charset='UTF-8')
|
||||||
meta(http-equiv="X-UA-Compatible" content="IE=edge")
|
meta(http-equiv="X-UA-Compatible" content="IE=edge")
|
||||||
@@ -72,7 +71,7 @@ if (theme.snackbar && theme.snackbar.enable)
|
|||||||
link(rel='stylesheet', href=url_for(theme.CDN.snackbar_css))
|
link(rel='stylesheet', href=url_for(theme.CDN.snackbar_css))
|
||||||
|
|
||||||
if theme.canonical
|
if theme.canonical
|
||||||
link(rel="canonical" href=without_html)
|
link(rel="canonical" href=urlNoIndex())
|
||||||
|
|
||||||
if is_post()
|
if is_post()
|
||||||
if(page.prev)
|
if(page.prev)
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ if theme.twitter_meta
|
|||||||
if theme.Open_Graph_meta
|
if theme.Open_Graph_meta
|
||||||
meta(property="og:type" content=contentType)
|
meta(property="og:type" content=contentType)
|
||||||
meta(property="og:title" content=pageTitle)
|
meta(property="og:title" content=pageTitle)
|
||||||
meta(property="og:url" content=without_html)
|
meta(property="og:url" content=urlNoIndex())
|
||||||
meta(property="og:site_name" content=config.title)
|
meta(property="og:site_name" content=config.title)
|
||||||
meta(property="og:description" content!=pageDescription)
|
meta(property="og:description" content!=pageDescription)
|
||||||
meta(property="og:image" content=full_url_for(page.cover || theme.avatar.img))
|
meta(property="og:image" content=full_url_for(page.cover || theme.avatar.img))
|
||||||
|
|||||||
@@ -1,3 +1,9 @@
|
|||||||
|
if (theme.facebook_comments.enable && page.comments !== false && !is_tag() && !is_category() && !is_archive() && !is_home())
|
||||||
|
if theme.facebook_comments.app_id
|
||||||
|
meta(property="fb:app_id" content=theme.facebook_comments.app_id )
|
||||||
|
if theme.facebook_comments.user_id
|
||||||
|
meta(property="fb:admins" content=theme.facebook_comments.user_id)
|
||||||
|
|
||||||
if (theme.disqusjs && theme.disqusjs.enable && page.comments !== false && !is_tag() && !is_category() && !is_archive() && !is_home())
|
if (theme.disqusjs && theme.disqusjs.enable && page.comments !== false && !is_tag() && !is_category() && !is_archive() && !is_home())
|
||||||
link(rel="stylesheet" type="text/css" href=url_for(theme.CDN.disqusjs_css))
|
link(rel="stylesheet" type="text/css" href=url_for(theme.CDN.disqusjs_css))
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,7 @@
|
|||||||
a.site-page.social-icon.search
|
a.site-page.social-icon.search
|
||||||
i.fa.fa-search.fa-fw
|
i.fa.fa-search.fa-fw
|
||||||
span=' '+_p('search')
|
span=' '+_p('search')
|
||||||
.menus_items
|
!=fragment_cache('menus', function(){return partial('includes/header/menu_item')})
|
||||||
include ./menu_item.pug
|
|
||||||
|
|
||||||
span.toggle-menu.close
|
span.toggle-menu.close
|
||||||
a.site-page
|
a.site-page
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ if theme.douban
|
|||||||
span#subtitle
|
span#subtitle
|
||||||
if(theme.social)
|
if(theme.social)
|
||||||
#site_social_icons
|
#site_social_icons
|
||||||
!=partial('includes/header/social', {}, {cache:theme.fragment_cache})
|
!=fragment_cache('social', function(){return partial('includes/header/social')})
|
||||||
#scroll_down
|
#scroll_down
|
||||||
i.fa.fa-angle-down.scroll-down-effects
|
i.fa.fa-angle-down.scroll-down-effects
|
||||||
else if is_post()
|
else if is_post()
|
||||||
|
|||||||
@@ -1,18 +1,19 @@
|
|||||||
each value, label in theme.menu
|
.menus_items
|
||||||
if !Array.isArray(value)
|
each value, label in theme.menu
|
||||||
.menus_item
|
if !Array.isArray(value)
|
||||||
a.site-page(href=url_for(trim(value.split('||')[0])))
|
.menus_item
|
||||||
i.fa-fw(class=trim(value.split('||')[1]))
|
a.site-page(href=url_for(trim(value.split('||')[0])))
|
||||||
span=' '+label
|
i.fa-fw(class=trim(value.split('||')[1]))
|
||||||
else
|
span=' '+label
|
||||||
.menus_item
|
else
|
||||||
a.site-page
|
.menus_item
|
||||||
i.fa-fw(class=trim(label.split('||')[1]) aria-hidden="true")
|
a.site-page
|
||||||
span=' '+ trim(label.split('||')[0])
|
i.fa-fw(class=trim(label.split('||')[1]) aria-hidden="true")
|
||||||
i.fa.fa-chevron-down.menus-expand(aria-hidden="true")
|
span=' '+ trim(label.split('||')[0])
|
||||||
ul.menus_item_child
|
i.fa.fa-chevron-down.menus-expand(aria-hidden="true")
|
||||||
each i in value
|
ul.menus_item_child
|
||||||
li
|
each i in value
|
||||||
a.site-page(href=url_for(trim(i.split('||')[1])))
|
li
|
||||||
i.fa-fw(class=trim(i.split('||')[2]))
|
a.site-page(href=url_for(trim(i.split('||')[1])))
|
||||||
span=' '+trim(i.split('||')[0])
|
i.fa-fw(class=trim(i.split('||')[2]))
|
||||||
|
span=' '+trim(i.split('||')[0])
|
||||||
@@ -82,3 +82,10 @@
|
|||||||
span= _p('post.comments') + ':'
|
span= _p('post.comments') + ':'
|
||||||
a(href=url_for(page.path) + '#post-comment')
|
a(href=url_for(page.path) + '#post-comment')
|
||||||
span.gitalk-comment-count.comment-count
|
span.gitalk-comment-count.comment-count
|
||||||
|
else if theme.facebook_comments.enable && theme.facebook_comments.count && page.comments !== false
|
||||||
|
if (postWordcount || theme.busuanzi.page_pv)
|
||||||
|
span.post-meta__separator |
|
||||||
|
i.post-meta__icon(class=commentCount aria-hidden="true")
|
||||||
|
span= _p('post.comments') + ':'
|
||||||
|
a.comment-count(href=url_for(page.path) + '#post-comment')
|
||||||
|
span.fb-comments-count(data-href=urlNoIndex())
|
||||||
@@ -23,5 +23,4 @@
|
|||||||
.headline= _p('aside.categories')
|
.headline= _p('aside.categories')
|
||||||
.length_num= site.categories.length
|
.length_num= site.categories.length
|
||||||
hr
|
hr
|
||||||
.menus_items
|
!=fragment_cache('menus', function(){return partial('includes/header/menu_item')})
|
||||||
include ../header/menu_item.pug
|
|
||||||
|
|||||||
@@ -31,4 +31,4 @@
|
|||||||
|
|
||||||
if(theme.social)
|
if(theme.social)
|
||||||
.card-info-social-icons.is-center
|
.card-info-social-icons.is-center
|
||||||
include ../header/social.pug
|
!=fragment_cache('social', function(){return partial('includes/header/social')})
|
||||||
|
|||||||
@@ -42,3 +42,12 @@ hexo.extend.helper.register('cloudTags', function (source, minfontsize, maxfonts
|
|||||||
})
|
})
|
||||||
return result
|
return result
|
||||||
})
|
})
|
||||||
|
|
||||||
|
hexo.extend.helper.register('urlNoIndex', function () {
|
||||||
|
const { permalink } = hexo.config
|
||||||
|
let url = this.url.replace(/index\.html$/, '')
|
||||||
|
if (!permalink.endsWith('.html')) {
|
||||||
|
url = url.replace(/\.html$/, '')
|
||||||
|
}
|
||||||
|
return url
|
||||||
|
})
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
margin: 0 .5rem
|
margin: 0 .5rem
|
||||||
color: $light-grey
|
color: $light-grey
|
||||||
text-shadow: .1rem .1rem .2rem rgba(0, 0, 0, .15)
|
text-shadow: .1rem .1rem .2rem rgba(0, 0, 0, .15)
|
||||||
font-size: .9rem
|
font-size: 1rem
|
||||||
cursor: pointer
|
cursor: pointer
|
||||||
|
|
||||||
#scroll_down
|
#scroll_down
|
||||||
|
|||||||
@@ -51,6 +51,7 @@
|
|||||||
|
|
||||||
.search-result
|
.search-result
|
||||||
margin: 0 0 .4rem
|
margin: 0 0 .4rem
|
||||||
|
word-break: break-all
|
||||||
|
|
||||||
.search-keyword
|
.search-keyword
|
||||||
color: $search-keyword-highlight
|
color: $search-keyword-highlight
|
||||||
|
|||||||
Reference in New Issue
Block a user