hexo-theme-butterfly/layout/includes/third-party/comments/facebook_comments.pug
Jerry de4037106b breaking changes: widget 寫法更改/可添加非sticky區域widget
feat: 升級facebook comment js 到 v10
fix: 修復當內容過少時, footer 沒有底部靠攏的bug
improvement: 404頁面不再顯示 rightside
2021-05-21 16:15:25 +08:00

27 lines
1018 B
Plaintext

#fb-root
script.
function loadFBComment () {
var themeNow = document.documentElement.getAttribute('data-theme') === 'dark' ? 'dark' : 'light'
document.getElementsByClassName('fb-comments')[0].setAttribute('data-colorscheme',themeNow)
if (typeof FB === 'object') FB.XFBML.parse()
else {
let ele = document.createElement('script')
ele.setAttribute('src','https://connect.facebook.net/!{theme.facebook_comments.lang}/sdk.js#xfbml=1&version=v10.0')
ele.setAttribute('async', 'true')
ele.setAttribute('defer', 'true')
ele.setAttribute('crossorigin', 'anonymous')
document.getElementById('fb-root').insertAdjacentElement('afterbegin',ele)
}
}
if ('!{theme.comments.use[0]}' === 'Facebook Comments' || !!{theme.comments.lazyload}) {
if (!{theme.comments.lazyload}) btf.loadComment(document.querySelector('#post-comment .fb-comments'), loadFBComment)
else loadFBComment()
} else {
function loadOtherComment () {
loadFBComment()
}
}