Skip to content

Commit

Permalink
Merge branch 'dev' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
jerryc127 committed Mar 18, 2021
2 parents 4c5abe0 + 65d8933 commit 6904850
Show file tree
Hide file tree
Showing 37 changed files with 345 additions and 284 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<div align="right">
Language:
🇺🇸
<a title="Chinese" href="/README_CN.md">🇨🇳</a>
</div>

# hexo-theme-butterfly

![master version](https://img.shields.io/github/package-json/v/jerryc127/hexo-theme-butterfly/master?color=%231ab1ad&label=master)
Expand Down
6 changes: 6 additions & 0 deletions README_CN.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<div align="right">
語言:
中文
<a title="English" href="/README.md">英文</a>
</div>

# hexo-theme-butterfly

![master version](https://img.shields.io/github/package-json/v/jerryc127/hexo-theme-butterfly/master?color=%231ab1ad&label=master)
Expand Down
28 changes: 12 additions & 16 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ menu:
# Tags: /tags/ || fas fa-tags
# Categories: /categories/ || fas fa-folder-open
# List||fas fa-list:
# - Music || /music/ || fas fa-music
# - Movie || /movies/ || fas fa-video
# Music: /music/ || fas fa-music
# Movie: /movies/ || fas fa-video
# Link: /link/ || fas fa-link
# About: /about/ || fas fa-heart

Expand All @@ -27,6 +27,7 @@ highlight_theme: light # darker / pale night / light / ocean / mac / mac light
highlight_copy: true # copy button
highlight_lang: true # show the code language
highlight_shrink: false # true: shrink the code blocks / false: expand the code blocks | none: expand code blocks and hide the button
highlight_height_limit: false # unit: px
code_word_wrap: false

# copy settings
Expand Down Expand Up @@ -83,7 +84,7 @@ favicon: /img/favicon.png

# Avatar (頭像)
avatar:
img:
img: https://i.loli.net/2021/02/24/5O1day2nriDzjSu.png
effect: false

# Disable all banner image
Expand Down Expand Up @@ -304,6 +305,7 @@ gitalk:
distractionFreeMode: false # Facebook-like distraction free mode.
pagerDirection: last # Comment sorting direction, available values are last and first.
createIssueManually: false # Gitalk will create a corresponding github issue for your every single page automatically
option:

# valine
# https://valine.js.org
Expand All @@ -321,6 +323,7 @@ valine:
emojiCDN: # emoji CDN
enableQQ: false # enable the Nickname box to automatically get QQ Nickname and QQ Avatar
requiredFields: nick,mail # required fields (nick/mail)
visitor: false
option:

# waline - A simple comment system with backend support fork from Valine
Expand All @@ -330,6 +333,7 @@ waline:
avatar: monsterid # gravatar style https://zh-tw.gravatar.com/site/implement/images/#default-image
emojiCDN: # emoji CDN
bg: # waline background
visitor: false
option:

# utterances
Expand All @@ -356,6 +360,7 @@ facebook_comments:
twikoo:
envId:
region:
visitor: false
option:

# Chat Services
Expand Down Expand Up @@ -788,14 +793,7 @@ note:
# other
# --------------------------------------

# Artitalk
# see https://artitalk.js.org/
artitalk:
appId:
appKey:
option:

# Pjax [Beta]
# Pjax
# It may contain bugs and unstable, give feedback when you find the bugs.
# https://github.com/MoOx/pjax
pjax:
Expand Down Expand Up @@ -899,8 +897,8 @@ CDN:
# math
mathjax: https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js
katex: https://cdn.jsdelivr.net/npm/katex@latest/dist/katex.min.css
katex_copytex: https://cdn.jsdelivr.net/npm/katex-copytex@latest/dist/katex-copytex.min.js
katex_copytex_css: https://cdn.jsdelivr.net/npm/katex-copytex@latest/dist/katex-copytex.min.css
katex_copytex: https://cdn.jsdelivr.net/npm/katex@latest/dist/contrib/copy-tex.min.js
katex_copytex_css: https://cdn.jsdelivr.net/npm/katex@latest/dist/contrib/copy-tex.css
mermaid: https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js

# count
Expand Down Expand Up @@ -949,6 +947,4 @@ CDN:
# Prism.js
prismjs_js: https://cdn.jsdelivr.net/npm/prismjs/prism.min.js
prismjs_lineNumber_js: https://cdn.jsdelivr.net/npm/prismjs/plugins/line-numbers/prism-line-numbers.min.js
prismjs_autoloader: https://cdn.jsdelivr.net/npm/prismjs/plugins/autoloader/prism-autoloader.min.js

artitalk: https://cdn.jsdelivr.net/npm/artitalk
prismjs_autoloader: https://cdn.jsdelivr.net/npm/prismjs/plugins/autoloader/prism-autoloader.min.js
2 changes: 1 addition & 1 deletion layout/includes/head/Open_Graph.pug
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
if theme.Open_Graph_meta
- let contentType = is_post() ? 'article' : 'website'
- let metaImage = full_url_for(page.cover || theme.avatar.img)
- let metaImage = (page.cover || theme.avatar.img) ? full_url_for(page.cover || theme.avatar.img) : ''
- let fb_appId = theme.facebook_comments.app_id || ''
- let fb_admins = theme.facebook_comments.user_id || ''

Expand Down
3 changes: 2 additions & 1 deletion layout/includes/head/config.pug
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@
highlight = JSON.stringify({
plugin: config.highlight.enable ? 'highlighjs' : 'prismjs',
highlightCopy: theme.highlight_copy,
highlightLang: theme.highlight_lang
highlightLang: theme.highlight_lang,
highlightHeightLimit: theme.highlight_height_limit
})
}
Expand Down
2 changes: 1 addition & 1 deletion layout/includes/header/index.pug
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
if !theme.disable_top_img && page.top_img !== false
if is_post()
- var top_img = page.top_img || page.cover || page.randomcover || theme.default_top_img
- var top_img = page.top_img || page.cover || page.randomcover
else if is_page()
- var top_img = page.top_img || theme.default_top_img
else if is_tag()
Expand Down
12 changes: 6 additions & 6 deletions layout/includes/header/menu_item.pug
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ if theme.menu

.menus_items
each value, label in theme.menu
if !Array.isArray(value)
if typeof value !== 'object'
.menus_item
a.site-page(href=url_for(trim(value.split('||')[0])))
if value.split('||')[1]
Expand All @@ -18,9 +18,9 @@ if theme.menu
span=' '+ trim(label.split('||')[0])
i.fas.fa-chevron-down.expand(class=sidebarChildHide)
ul.menus_item_child
each i in value
each val,lab in value
li
a.site-page(href=url_for(trim(i.split('||')[1])))
if i.split('||')[2]
i.fa-fw(class=trim(i.split('||')[2]))
span=' '+trim(i.split('||')[0])
a.site-page.child(href=url_for(trim(val.split('||')[0])))
if val.split('||')[1]
i.fa-fw(class=trim(val.split('||')[1]))
span=' '+ lab
2 changes: 1 addition & 1 deletion layout/includes/header/nav.pug
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ nav#nav
a.site-page.social-icon.search
i.fas.fa-search.fa-fw
span=' '+_p('search')
!=fragment_cache('menus', function(){return partial('includes/header/menu_item')})
!=partial('includes/header/menu_item', {}, {cache: true})

#toggle-menu
a.site-page
Expand Down
22 changes: 18 additions & 4 deletions layout/includes/header/post-info.pug
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- let comments = theme.comments
#post-info
h1.post-title= page.title || _p('no_title')
if theme.post_edit.enable
Expand Down Expand Up @@ -51,15 +52,28 @@
span.post-meta-label= _p('post.min2read') + ':'
span= min2read(page.content, {cn: 350, en: 160}) + _p('post.min2read_unit')

if theme.busuanzi.page_pv
//- for pv and count
mixin pvBlock(parent_id,parent_class,parent_title)
span.post-meta-separator |
span.post-meta-pv-cv
span(class=parent_class id=parent_id data-flag-title=page.title)
i.far.fa-eye.fa-fw.post-meta-icon
span.post-meta-label=_p('post.page_pv') + ':'
if block
block

if theme.busuanzi.page_pv
+pvBlock('','post-meta-pv-cv','')
span#busuanzi_value_page_pv
else if comments.use && !comments.lazyload
if (comments.use.includes('Valine') && theme.valine.visitor) || (comments.use.includes('Waline') && theme.waline.visitor)
+pvBlock(url_for(page.path),'leancloud_visitors',page.title)
span.leancloud-visitors-count
else if (comments.use.includes('Twikoo') && theme.twikoo.visitor)
+pvBlock('','','')
span#twikoo_visitors

if !theme.comments.lazyload && page.comments !== false && theme.comments.use && theme.comments.count
- var whichCount = theme.comments.use[0]
if comments.count && !comments.lazyload && page.comments !== false && comments.use
- var whichCount = comments.use[0]

mixin countBlock
span.post-meta-separator |
Expand Down
28 changes: 0 additions & 28 deletions layout/includes/page/artitalk.pug

This file was deleted.

14 changes: 8 additions & 6 deletions layout/includes/pagination.pug
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
escape: false
}
if(!is_post())
nav#pagination
div.pagination
!=paginator(options)
else
if is_post()
- let prev = theme.post_pagination === 1 ? page.prev : page.next
- let next = theme.post_pagination === 1 ? page.next : page.prev
nav#pagination.pagination-post
Expand Down Expand Up @@ -38,4 +34,10 @@ else
img.next-cover(src=url_for(pagination_cover) onerror=`onerror=null;src='${url_for(theme.error_img.post_page)}'` alt='cover of next post')
.pagination-info
.label=_p('pagination.next')
.next_info=next.title
.next_info=next.title
else
nav#pagination
.pagination
if is_home()
- options.format = 'page/%d/#content-inner'
!=paginator(options)
2 changes: 1 addition & 1 deletion layout/includes/sidebar.pug
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@
.headline= _p('aside.categories')
.length-num= site.categories.length
hr
!=fragment_cache('menus', function(){return partial('includes/header/menu_item')})
!=partial('includes/header/menu_item', {}, {cache: true})
5 changes: 3 additions & 2 deletions layout/includes/third-party/comments/gitalk.pug
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ script.

function loadGitalk () {
function initGitalk () {
var gitalk = new Gitalk({
var gitalk = new Gitalk(Object.assign({
clientID: '!{theme.gitalk.client_id}',
clientSecret: '!{theme.gitalk.client_secret}',
repo: '!{theme.gitalk.repo}',
Expand All @@ -21,7 +21,8 @@ script.
pagerDirection: '!{theme.gitalk.pagerDirection}',
createIssueManually: !{theme.gitalk.createIssueManually},
updateCountCallback: commentCount
})
},!{JSON.stringify(theme.gitalk.option)}))

gitalk.render('gitalk-container')
}

Expand Down
13 changes: 2 additions & 11 deletions layout/includes/third-party/comments/twikoo.pug
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
- let option = theme.twikoo.option ? JSON.stringify(theme.twikoo.option) : false

script.
(()=>{
const $countDom = document.getElementById('twikoo-count')
const init = () => {
let initData = {
twikoo.init(Object.assign({
el: '#twikoo-wrap',
envId: '!{theme.twikoo.envId}',
region: '!{theme.twikoo.region}'
}

if (!{Boolean(option)}) {
const otherData = !{option}
initData = Object.assign(initData, otherData)
}

twikoo.init(initData)
}, !{JSON.stringify(theme.twikoo.option)}))
}

const getCount = () => {
Expand Down
18 changes: 4 additions & 14 deletions layout/includes/third-party/comments/valine.pug
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
- let option = theme.valine.option ? JSON.stringify(theme.valine.option) : false
- let emojiMaps = '""'
if site.data.valine
- emojiMaps = JSON.stringify(site.data.valine)

script.
function loadValine () {
function initValine () {
let initData = {
const valine = new Valine(Object.assign({
el: '#vcomment',
appId: '#{theme.valine.appId}',
appKey: '#{theme.valine.appKey}',
Expand All @@ -21,18 +20,9 @@ script.
emojiMaps: !{emojiMaps},
enableQQ: #{theme.valine.enableQQ},
path: window.location.pathname,
}

if (!{Boolean(theme.valine.requiredFields)}) {
initData.requiredFields= ('!{theme.valine.requiredFields}'.split(','))
}

if (!{Boolean(option)}) {
const otherData = !{option}
initData = Object.assign(initData, otherData)
}

const valine = new Valine(initData)
requiredFields: [!{theme.valine.requiredFields ? JSON.stringify(theme.valine.requiredFields).split(',') : ''}],
visitor: #{theme.valine.visitor}
}, !{JSON.stringify(theme.valine.option)}))
}

if (typeof Valine === 'function') initValine()
Expand Down
13 changes: 3 additions & 10 deletions layout/includes/third-party/comments/waline.pug
Original file line number Diff line number Diff line change
@@ -1,26 +1,19 @@
- let option = theme.waline.option ? JSON.stringify(theme.waline.option) : false
- let emojiMaps = '""'
if site.data.waline
- emojiMaps = JSON.stringify(site.data.waline)

script.
function loadWaline () {
function initWaline () {
let initData = {
const waline = new Waline(Object.assign({
el: '#waline-wrap',
serverURL: '!{theme.waline.serverURL}',
avatar: '#{theme.waline.avatar}',
path: location.pathname,
emojiCDN: '#{theme.waline.emojiCDN}',
emojiMaps: !{emojiMaps},
}

if (!{Boolean(option)}) {
const otherData = !{option}
initData = Object.assign(initData, otherData)
}

const waline = new Waline(initData)
visitor: #{theme.waline.visitor}
}, !{JSON.stringify(theme.waline.option)}))
}

if (typeof Waline === 'function') initWaline()
Expand Down
Loading

0 comments on commit 6904850

Please sign in to comment.