Skip to content

Commit

Permalink
Merge branch 'add-social-style' of https://github.com/JamesY-Jey/hexo…
Browse files Browse the repository at this point in the history
…-theme-butterfly into add-social-style
  • Loading branch information
JamesY-Jey committed Apr 4, 2023
2 parents 47214b5 + d62f047 commit 5e30032
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 2 deletions.
8 changes: 8 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,13 @@ fancybox: true
# Tag Plugins settings (標籤外掛)
# --------------------------------------

# abcjs (樂譜渲染)
# See https://github.com/paulrosen/abcjs
# ---------------
abcjs:
enable: false
per_page: true

# mermaid
# see https://github.com/mermaid-js/mermaid
mermaid:
Expand Down Expand Up @@ -967,3 +974,4 @@ CDN:
# artalk_js:
# artalk_css:
# busuanzi:
# abcjs_basic_js:
2 changes: 2 additions & 0 deletions layout/includes/additional-js.pug
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ div

include ./third-party/math/index.pug

include ./third-party/abcjs/index.pug

if commentsJsLoad
include ./third-party/comments/js.pug

Expand Down
15 changes: 15 additions & 0 deletions layout/includes/third-party/abcjs/abcjs.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
script.
(() => {
function abcjsInit() {
function abcjsFn() {
for (let abcContainer of document.getElementsByClassName("abc-music-sheet")) {
ABCJS.renderAbc(abcContainer, abcContainer.innerHTML, {responsive: 'resize'})
}
}

typeof ABCJS === 'object' ? abcjsFn()
: getScript('!{url_for(theme.asset.abcjs_basic_js)}').then(abcjsFn)
}

window.pjax ? abcjsInit() : document.addEventListener('DOMContentLoaded', abcjsInit)
})()
6 changes: 6 additions & 0 deletions layout/includes/third-party/abcjs/index.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
if theme.abcjs.enable
if theme.abcjs.per_page
if is_post() || is_page()
include ./abcjs.pug
else if page.abcjs
include ./abcjs.pug
4 changes: 4 additions & 0 deletions plugins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -208,3 +208,7 @@ docsearch_css:
other_name: docsearch-css
file: dist/style.css
version: 3.3.3
abcjs_basic_js:
name: abcjs
file: dist/abcjs-basic-min.js
version: 6.1.9
22 changes: 22 additions & 0 deletions scripts/tag/score.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* Music Score
* {% score %}
*/

'use strict';

function score(args, content) {
function escapeHtmlTags(s) {
let lookup = {
'&': "&",
'"': """,
'\'': "'",
'<': "&lt;",
'>': "&gt;"
};
return s.replace(/[&"'<>]/g, c => lookup[c]);
}
return `<div class="abc-music-sheet">${escapeHtmlTags(content)}</div>`;
}

hexo.extend.tag.register('score', score, {ends: true});
10 changes: 9 additions & 1 deletion source/css/_layout/third-party.styl
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,14 @@ span.mathjax-overflow
.snackbar-css
border-radius: 5px !important

.abc-music-sheet
margin: 0 0 20px
opacity: 0
transition: opacity .3s

&.abcjs-container
opacity: 1

+maxWidth768()
.fancybox__toolbar__column.is-middle
display: none
display: none
2 changes: 1 addition & 1 deletion source/css/_page/common.styl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
padding: 20px 5px

+minWidth2000()
max-width: 1500px
max-width: 1700px

& > div:first-child:not(.recent-posts)
@extend .cardHover
Expand Down

0 comments on commit 5e30032

Please sign in to comment.