Skip to content

Commit

Permalink
feat(prettify): minor changes
Browse files Browse the repository at this point in the history
- Remove the custom_css
- Add public cdn support
- Only load prettify at post pages
  • Loading branch information
neoFelhz committed Jun 16, 2017
1 parent ff2823c commit ade6150
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
9 changes: 4 additions & 5 deletions _config.template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,8 @@ qrcode:
# highlight:
# enable: false
prettify:
enable: false # if true, customcss.enable must be true
theme: "vibrant-ink" # default value: "vibrant-ink" # "theme-name without .css"
customcss:
enable: false
csspath: "/css/custom-prettify.min.css"
enable: false
theme: "vibrant-ink" # default value: "vibrant-ink" # theme-name without '.css'

# ---------------------------------------------------------------
# Menu Settings
Expand Down Expand Up @@ -266,3 +263,5 @@ vendors:
fontawesome:
# MathJax 2.7.0-2.7.1
mathjax:
# Prettify r298 (only prettify.js)
prettify:
28 changes: 17 additions & 11 deletions layout/_partial/import_js.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,31 @@
}
</script>

<!-- prettify代码高亮js引入 -->
<!-- Import prettify js -->
<% if (theme.prettify.enable){ %>
<script src="/vendors/prettify/prettify.js" type="text/javascript"></script>
<%}%>
<% if(theme.vendors.prettify) { %>
<%- jsLsload({path:(theme.vendors.prettify),key:'prettify_js'}) %>
<% } else { %>
<%- jsLsload({path:(config.root + 'js/prettify.min.js'),key:'prettify_js'}) %>
<% } %>
<% } %>

<!-- Window Load-->
<!-- Window Load -->
<!-- add class for prettify -->
<script type="text/ls-javascript" id="window-load">
$(window).on('load', function() {
// Post_Toc parent position fixed
$('.post-toc-wrap').parent('.mdl-menu__container').css('position', 'fixed');
});
$(function() {
<!-- prettify代码高亮js引入 -->
<% if (theme.prettify.enable){ %>
$('pre').addClass('prettyprint linenums').attr('style', 'overflow:auto;');
prettyPrint();
<%}%>
})
<% if (theme.prettify.enable) { %>
<% if ( (is_post()) ) { %>
$(function() {
$('pre').addClass('prettyprint linenums').attr('style', 'overflow:auto;');
prettyPrint();
})
<% } %>
<% } %>
</script>

<!-- MathJax Load-->
Expand Down
1 change: 1 addition & 0 deletions source/js/prettify.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ade6150

Please sign in to comment.