forked from fluid-dev/hexo-theme-fluid
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
368 additions
and
292 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<% | ||
import_script(` | ||
<script> | ||
Fluid.utils.createScript('${ url_join(theme.static_prefix.anchor, 'anchor.min.js') }', function() { | ||
window.anchors.options = { | ||
placement: CONFIG.anchorjs.placement, | ||
visible : CONFIG.anchorjs.visible | ||
}; | ||
if (CONFIG.anchorjs.icon) { | ||
window.anchors.options.icon = CONFIG.anchorjs.icon; | ||
} | ||
var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(','); | ||
var res = []; | ||
for (var item of el) { | ||
res.push('.markdown-body > ' + item.trim()); | ||
} | ||
if (CONFIG.anchorjs.placement === 'left') { | ||
window.anchors.options.class = 'anchorjs-link-left'; | ||
} | ||
window.anchors.add(res.join(', ')); | ||
}); | ||
</script> | ||
`) | ||
%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<% | ||
import_script(`<script> | ||
(function() { | ||
var enableLang = CONFIG.code_language.enable && CONFIG.code_language.default; | ||
var enableCopy = CONFIG.copy_btn; | ||
if (!enableLang && !enableCopy) { | ||
return; | ||
} | ||
function getBgClass(ele) { | ||
if (ele.length === 0) { | ||
return 'code-widget-light'; | ||
} | ||
var rgbArr = ele.css('background-color').replace(/rgba*\\(/, '').replace(')', '').split(','); | ||
var color = (0.213 * rgbArr[0]) + (0.715 * rgbArr[1]) + (0.072 * rgbArr[2]) > 255 / 2; | ||
return color ? 'code-widget-light' : 'code-widget-dark'; | ||
} | ||
var copyTmpl = ''; | ||
copyTmpl += '<div class="code-widget">'; | ||
copyTmpl += 'LANG'; | ||
copyTmpl += '</div>'; | ||
jQuery('.markdown-body pre').each(function() { | ||
var $pre = jQuery(this); | ||
if ($pre.find('code.mermaid').length > 0) { | ||
return; | ||
} | ||
if ($pre.find('span.line').length > 0) { | ||
return; | ||
} | ||
var lang = ''; | ||
if (enableLang) { | ||
lang = CONFIG.code_language.default; | ||
if ($pre[0].children.length > 0 && $pre[0].children[0].classList.length >= 2 && $pre.children().hasClass('hljs')) { | ||
lang = $pre[0].children[0].classList[1]; | ||
} else if ($pre[0].getAttribute('data-language')) { | ||
lang = $pre[0].getAttribute('data-language'); | ||
} else if ($pre.parent().hasClass('sourceCode') && $pre[0].children.length > 0 && $pre[0].children[0].classList.length >= 2) { | ||
lang = $pre[0].children[0].classList[1]; | ||
$pre.parent().addClass('code-wrapper'); | ||
} else if ($pre.parent().hasClass('markdown-body') && $pre[0].classList.length === 0) { | ||
$pre.wrap('<div class="code-wrapper"></div>'); | ||
} | ||
lang = lang.toUpperCase().replace(/(LIVECODESERVER|NONE)/, CONFIG.code_language.default); | ||
} | ||
$pre.append(copyTmpl.replace('LANG', lang).replace('code-widget">', | ||
getBgClass($pre) + (enableCopy ? ' code-widget copy-btn" data-clipboard-snippet><i class="iconfont icon-copy"></i>' : ' code-widget">'))); | ||
if (enableCopy) { | ||
Fluid.utils.createScript('${url_join(theme.static_prefix.clipboard, 'clipboard.min.js')}', function() { | ||
var clipboard = new window.ClipboardJS('.copy-btn', { | ||
target: function(trigger) { | ||
var nodes = trigger.parentNode.childNodes; | ||
for (var i = 0; i < nodes.length; i++) { | ||
if (nodes[i].tagName === 'CODE') { | ||
return nodes[i]; | ||
} | ||
} | ||
} | ||
}); | ||
clipboard.on('success', function(e) { | ||
e.clearSelection(); | ||
e.trigger.innerHTML = e.trigger.innerHTML.replace('icon-copy', 'icon-success'); | ||
setTimeout(function() { | ||
e.trigger.innerHTML = e.trigger.innerHTML.replace('icon-success', 'icon-copy'); | ||
}, 2000); | ||
}); | ||
}); | ||
} | ||
}); | ||
})(); | ||
</script> | ||
`) | ||
%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<% | ||
import_css(theme.static_prefix.fancybox, 'jquery.fancybox.min.css') | ||
import_script(` | ||
<script> | ||
Fluid.utils.createScript('${url_join(theme.static_prefix.fancybox, 'jquery.fancybox.min.js')}', function() { | ||
Fluid.plugins.fancyBox(); | ||
}); | ||
</script> | ||
`) | ||
%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<% | ||
var cssName | ||
if (theme.code.highlight.lib === 'highlightjs') { | ||
cssName = theme.code.highlight.highlightjs.style.toLowerCase().replace(/([^0-9])\s([^0-9])/g, '$1-$2').replace(/\s/g, '') | ||
if (cssName === 'github-gist' && require_version(theme.static_prefix.highlightjs, '11.0.0')) { | ||
cssName = 'github' | ||
} | ||
import_css(theme.static_prefix.highlightjs, `/styles/${cssName}.min.css`) | ||
} else if (theme.code.highlight.lib === 'prismjs') { | ||
var style = theme.code.highlight.prismjs.style | ||
if (/\.css$/.test(style)) { | ||
import_css(theme.static_prefix.prismjs, style) | ||
} else { | ||
if (!style || style === 'default') { | ||
cssName = '' | ||
} else { | ||
cssName = style.toLowerCase().replace(/[\s\-]/g, '') | ||
if (cssName === 'prism') { | ||
cssName = '' | ||
} | ||
if (cssName === 'tomorrownight') { | ||
cssName = 'tomorrow' | ||
} | ||
} | ||
import_css(theme.static_prefix.prismjs, `/themes/${cssName ? 'prism-' + cssName : 'prism'}.min.css`) | ||
} | ||
if (!theme.code.highlight.prismjs.preprocess) { | ||
import_js(theme.static_prefix.prismjs, 'components/prism-core.min.js') | ||
import_js(theme.static_prefix.prismjs, 'plugins/autoloader/prism-autoloader.min.js') | ||
} | ||
if (theme.code.highlight.line_number) { | ||
import_css(theme.static_prefix.prismjs, '/plugins/line-numbers/prism-line-numbers.min.css') | ||
import_js(theme.static_prefix.prismjs, '/plugins/line-numbers/prism-line-numbers.min.js') | ||
} | ||
} | ||
%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<% if(theme.post.math.engine === 'mathjax') { %> | ||
<% | ||
var lazy = theme.lazyload.enable && require_version(theme.static_prefix.mathjax, '3.2.0') | ||
import_script(` | ||
<script> | ||
MathJax = { | ||
tex : { | ||
inlineMath: [['$', '$'], ['\\(', '\\)']] | ||
}, | ||
loader : { | ||
${ lazy ? 'load: \[\'ui/lazy\'\]' : '' } | ||
}, | ||
options: { | ||
renderActions: { | ||
findScript : [10, doc => { | ||
document.querySelectorAll('script[type^="math/tex"]').forEach(node => { | ||
const display = !!node.type.match(/; *mode=display/); | ||
const math = new doc.options.MathItem(node.textContent, doc.inputJax[0], display); | ||
const text = document.createTextNode(''); | ||
node.parentNode.replaceChild(text, node); | ||
math.start = { node: text, delim: '', n: 0 }; | ||
math.end = { node: text, delim: '', n: 0 }; | ||
doc.math.push(math); | ||
}); | ||
}, '', false], | ||
insertedScript: [200, () => { | ||
document.querySelectorAll('mjx-container').forEach(node => { | ||
let target = node.parentNode; | ||
if (target.nodeName.toLowerCase() === 'li') { | ||
target.parentNode.classList.add('has-jax'); | ||
} | ||
}); | ||
}, '', false] | ||
} | ||
} | ||
}; | ||
</script> | ||
`) | ||
import_js(theme.static_prefix.mathjax, 'tex-svg.js') | ||
%> | ||
<% } else if (theme.post.math.engine === 'katex') { %> | ||
<% import_css(theme.static_prefix.katex, 'katex.min.css') %> | ||
<% } %> |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.