From 57bc4fecd6454eb37c45c7d586cd725d3adf96bd Mon Sep 17 00:00:00 2001 From: xaoxuu Date: Thu, 27 Dec 2018 17:49:14 +0800 Subject: [PATCH] update --- _config.yml | 42 +++- layout/_partial/footer.ejs | 25 +- layout/_partial/head.ejs | 19 +- layout/_partial/meta.ejs | 6 +- layout/_partial/scripts.ejs | 380 +++++++++++++++++-------------- layout/_third-party/aplayer.ejs | 28 +-- layout/_third-party/comments.ejs | 22 +- layout/_widget/music.ejs | 2 +- source/js/app.js | 18 +- 9 files changed, 300 insertions(+), 242 deletions(-) diff --git a/_config.yml b/_config.yml index 6e4230f..512a5ed 100755 --- a/_config.yml +++ b/_config.yml @@ -1,20 +1,39 @@ -########################################################################## -############################## 主题基本信息 ################################ -theme_info: +# 这一页的内容可以修改值,但是不要删除行。初次使用主题请务必阅读官方文档!!! +# 这一页的内容可以修改值,但是不要删除行。初次使用主题请务必阅读官方文档!!! +# 这一页的内容可以修改值,但是不要删除行。初次使用主题请务必阅读官方文档!!! + + +############################### 基本信息 ############################### +info: name: Material X version: 1.0-beta11 docs: https://xaoxuu.com/wiki/material-x/ - # 主题的CDN地址,如果你的源码托管到国内CDN可以更改此链接。如需启用CDN,请在主目录的config中设置import,详见文档。 - cdn: https://cdn.jsdelivr.net/gh/xaoxuu/cdn-material-x@18.12.36/ -########################################################################## -# 请务必阅读官方文档!!! -# 请务必阅读官方文档!!! -# 请务必阅读官方文档!!! + # 主题的CDN地址。如需启用CDN,请在主目录的config中设置,详见文档。 + cdn: https://cdn.jsdelivr.net/gh/xaoxuu/cdn-material-x@18.12.37/ + + +############################### 主题样式 ############################### +# style: material # material: 导航栏和标题栏背景是主题色 +style: pure # pure: 导航栏和标题栏背景是白色 -# style: material # 导航栏和标题栏背景是主题色 -style: pure # 导航栏和标题栏背景是白色 +############################### 服务开关 ############################### +# 服务开关,如果你想禁用某些功能,直接设置为false或者注释掉,相关的js脚本就不会加载。 +# 有些服务这里打开了也未必会生效,还需要额外的配置,详见文档。 +services: + cdn: true + scrollreveal: true + nodewaves: true + busuanzi: true + # fastclick: true + leancloud_visitors: true + recommended_posts: true # 需要安装"hexo-recommended-posts": "^1.0.3", + comments: true + music: true + + +############################### 杂项 ############################### # 这里的widgets字段是对widget的默认设置,如需修改请参照文档在主目录的config中写。 widgets: # 文章分类的默认配置 @@ -41,6 +60,7 @@ widgets: post: true # layout: post 的页面是否显示 + # 推荐文章 recommended_posts: autoDisplay: false # 自动在文章底部显示推荐文章,如果你使用Material-X主题,这里要设置为false。 diff --git a/layout/_partial/footer.ejs b/layout/_partial/footer.ejs index e960c37..169db23 100755 --- a/layout/_partial/footer.ejs +++ b/layout/_partial/footer.ejs @@ -1,16 +1,15 @@ diff --git a/layout/_partial/head.ejs b/layout/_partial/head.ejs index a3834f9..4535ba7 100755 --- a/layout/_partial/head.ejs +++ b/layout/_partial/head.ejs @@ -43,6 +43,11 @@ <% }) %> <% } %> + <% if (theme.services && theme.services.nodewaves == true) { %> + + <% } %> + + <% if (config.import && config.import.link){ %> <% (config.import.link||[]).forEach(function(item){ %> <% } %> - - <% if (config.import && config.import.style == true) { %> - <%- css(theme.theme_info.cdn + 'css/style.css') %> - <% } else if (config.import && config.import.style && config.import.style.length > 0){ %> - <%- css(config.import.style) %> + <% if (theme.services && theme.services.cdn == true) { %> + <%- css(theme.info.cdn + 'css/style.css') %> <% } else { %> <%- css('style.css') %> <% } %> - - + <% if (config.import && config.import.css && config.import.css.length > 0) { %> + <%- css(config.import.css) %> + <% } %> + + - - - - - - - - -<% if (config.import && config.import.js == true) { %> - <%- js([theme.theme_info.cdn + 'js/app.js', theme.theme_info.cdn + 'js/search.js']) %> -<% } else if (config.import && config.import.js && config.import.js.length > 0) { %> - <%- js(config.import.js) %> -<% } else { %> - <%- js(['js/app.js', 'js/search.js']) %> -<% } %> - <% if (theme.search && theme.search.enable) { %> <% } %> - -<% if ((page.layout == 'post' && page.comments != false) || page.comments == true) { %> - <% if (config.disqus_shortname){ %> - + <% } %> - <% if (config.livere_uid){ %> + <% if (theme.services.nodewaves == true) { %> + <% } %> - <% if (config.valine){ %> - <% if (config.valine.enable && config.valine.app_id && config.valine.app_key){ %> - - <% if (config.import && config.import.js == true) { %> - - <% } else { %> - <%- js('js/volantis.js') %> - <% } %> - - <% } %> + <% if (theme.services.busuanzi == true) { %> + <% } %> -<% } %> - - -<% if (config.leancloud_visitors && config.leancloud_visitors.app_id && config.leancloud_visitors.app_key) { %> - - - + + <% } %> + <% if (theme.services.leancloud_visitors == true) { %> + + <% if (config.leancloud_visitors && config.leancloud_visitors.app_id && config.leancloud_visitors.app_key) { %> + + + + <% } %> + <% } %> + <% + var displayComments = false; + if (page && theme.services) { + if ((config.disqus_shortname || config.livere_shortname || config.valine) && theme.services.comments == true && page.comments != false) { + displayComments = true; + } } - }); - + %> + <% if (displayComments == true) { %> + <% if ((page.layout == 'post' && page.comments != false) || page.comments == true) { %> + <% if (config.disqus_shortname){ %> + + <% } %> + <% if (config.livere_uid){ %> + + <% } %> + <% if (config.valine){ %> + <% if (config.valine.enable && config.valine.app_id && config.valine.app_key){ %> + + <% if (theme.services && theme.services.cdn == true) { %> + + <% } else { %> + <%- js('js/volantis.js') %> + <% } %> + + <% } %> + <% } %> + <% } %> + <% } %> + <% if (theme.services.cdn == true) { %> + <%- js([theme.info.cdn + 'js/app.js', theme.info.cdn + 'js/search.js']) %> + <% } else { %> + <%- js(['js/app.js', 'js/search.js']) %> + <% } %> +<% } %> + +<% if (config.import && config.import.js && config.import.js.length > 0) { %> + <%- js(config.import.js) %> <% } %> diff --git a/layout/_third-party/aplayer.ejs b/layout/_third-party/aplayer.ejs index a1be6fb..c084f18 100644 --- a/layout/_third-party/aplayer.ejs +++ b/layout/_third-party/aplayer.ejs @@ -1,13 +1,15 @@ - -
data-mini=true <%}%> - <%if(aplayer_autoplay){%>data-autoplay=true <%}%> - data-mode="<%- aplayer_mode %>" - data-server="<%= aplayer_server %>" - data-type="<%= aplayer_type %>" - data-id="<%= aplayer_id %>" - data-volume="<%= aplayer_volume %>"> -
- - +<% if (theme.services && theme.services.music == true) { %> + +
data-mini=true <%}%> + <%if(aplayer_autoplay){%>data-autoplay=true <%}%> + data-mode="<%- aplayer_mode %>" + data-server="<%= aplayer_server %>" + data-type="<%= aplayer_type %>" + data-id="<%= aplayer_id %>" + data-volume="<%= aplayer_volume %>"> +
+ + +<% } %> diff --git a/layout/_third-party/comments.ejs b/layout/_third-party/comments.ejs index 8b1f5f2..4259f6a 100644 --- a/layout/_third-party/comments.ejs +++ b/layout/_third-party/comments.ejs @@ -1,14 +1,26 @@ -<% if (page && ((theme.recommended_posts && theme.recommended_posts.autoDisplay == false && page.recommended_posts != false) || (page.comments && (config.disqus_shortname || config.livere_shortname || config.valine)) )) { %> +<% + var displayRecommentedPosts = false; + var displayComments = false; + if (page && theme.services) { + if (theme.services.recommended_posts == true && theme.recommended_posts && theme.recommended_posts.autoDisplay == false && page.layout == 'post' && page.recommended_posts != false) { + displayRecommentedPosts = true; + } + if ((config.disqus_shortname || config.livere_shortname || config.valine) && theme.services.comments == true && page.comments != false) { + displayComments = true; + } + } +%> + +<% if (displayRecommentedPosts || displayComments) { %>
- <% if (theme.recommended_posts && theme.recommended_posts.autoDisplay == false && page.recommended_posts != false) { %> + <% if (displayRecommentedPosts) { %> <%- partial('recommended_posts', {page: page, site: site}) %> <% } %> - <% if (page.comments) { %> - + <% if (displayComments) { %>

 评论

<% if (config.disqus_shortname) { %>
@@ -17,7 +29,6 @@
<% } %> - <% if (config.livere_uid){ %>
@@ -25,7 +36,6 @@
<% } %> - <% if (config.valine){ %> <% if (config.valine.enable && config.valine.app_id && config.valine.app_key){ %>
diff --git a/layout/_widget/music.ejs b/layout/_widget/music.ejs index 560693a..3d1c72d 100755 --- a/layout/_widget/music.ejs +++ b/layout/_widget/music.ejs @@ -38,7 +38,7 @@ if (theme.widgets.music && theme.widgets.music.display) { } %> -<% if (needDisplay == true) { %> +<% if (theme.services && theme.services.music == true && needDisplay == true) { %>
<%- partial('header', {item: item, defIcon: '', defTitle: ''}) %>
diff --git a/source/js/app.js b/source/js/app.js index 31264bd..59b6c91 100755 --- a/source/js/app.js +++ b/source/js/app.js @@ -135,21 +135,6 @@ var customSearch; }); } - function setWaves() { - Waves.attach('.flat-btn', ['waves-button']); - Waves.attach('.float-btn', ['waves-button', 'waves-float']); - Waves.attach('.float-btn-light', ['waves-button', 'waves-float', 'waves-light']); - Waves.attach('.flat-box', ['waves-block']); - Waves.attach('.float-box', ['waves-block', 'waves-float']); - Waves.attach('.waves-image'); - Waves.init(); - } - function setScrollReveal() { - const $reveal = $('.reveal'); - if ($reveal.length === 0) return; - const sr = ScrollReveal({ distance: 0 }); - sr.reveal('.reveal'); - } function setTocToggle() { const $toc = $('.toc-wrapper'); if ($toc.length === 0) return; @@ -206,8 +191,7 @@ var customSearch; setHeaderMenu(); setHeaderMenuPhone(); setHeaderSearch(); - setWaves(); - setScrollReveal(); + setTocToggle(); // $(".article .video-container").fitVids();