diff --git a/layout/_layout.njk b/layout/_layout.njk
index 5507cfb..82b01bb 100644
--- a/layout/_layout.njk
+++ b/layout/_layout.njk
@@ -3,9 +3,12 @@
{{ partial('_partials/head/head.njk', {}, {cache: theme.cache.enable}) }}
{%- include '_partials/head/head-unique.njk' -%}
+ {{- next_js('load-config.js', true) }}
{% block title %}{% endblock %}
{{ partial('_third-party/analytics/index.njk', {}, {cache: theme.cache.enable}) }}
- {{ partial('_scripts/noscript.njk', {}, {cache: theme.cache.enable}) }}
+
diff --git a/layout/_partials/comments.njk b/layout/_partials/comments.njk
index 030b383..0d5a494 100644
--- a/layout/_partials/comments.njk
+++ b/layout/_partials/comments.njk
@@ -14,31 +14,7 @@
{{ partial(inject_item.layout, inject_item.locals, inject_item.options) }}
{%- endfor %}
-
+ {{- next_js('comments-buttons.js', true) }}
{%- elif theme.comments.style == 'tabs' %}
@@ -58,24 +34,4 @@ {%- endif %} {%- endif %} - +{{- next_js('comments.js') }} diff --git a/layout/_partials/footer.njk b/layout/_partials/footer.njk index 4241c9b..c4534ab 100644 --- a/layout/_partials/footer.njk +++ b/layout/_partials/footer.njk @@ -2,7 +2,7 @@
{{- next_url('https://beian.miit.gov.cn', theme.footer.beian.icp + ' ') }}
{%- if theme.footer.beian.gongan_icon_url %}
-
+
{%- endif %}
{%- if theme.footer.beian.gongan_id and theme.footer.beian.gongan_num %}
{{- next_url('http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=' + theme.footer.beian.gongan_id, theme.footer.beian.gongan_num + ' ') }}
@@ -51,7 +51,7 @@
{%- if theme.busuanzi_count.enable %}
{%- if theme.busuanzi_count.total_visitors %}
-
+
@@ -62,7 +62,7 @@
{%- endif %}
{%- if theme.busuanzi_count.total_views %}
-
+
diff --git a/layout/_partials/head/head-unique.njk b/layout/_partials/head/head-unique.njk
index f9bcfe2..12981e7 100644
--- a/layout/_partials/head/head-unique.njk
+++ b/layout/_partials/head/head-unique.njk
@@ -8,14 +8,18 @@
{# Exports some front-matter variables to Front-End #}
-
+{# https://hexo.io/docs/variables.html #}
+
+
{{- next_inject('head') }}
diff --git a/layout/_partials/head/head.njk b/layout/_partials/head/head.njk
index 4aed5d7..6601ece 100644
--- a/layout/_partials/head/head.njk
+++ b/layout/_partials/head/head.njk
@@ -53,4 +53,4 @@
{%- endif %}
-{{ next_config() }}
+
diff --git a/layout/_partials/page/schedule.njk b/layout/_partials/page/schedule.njk
index ce00cd4..f21bc35 100644
--- a/layout/_partials/page/schedule.njk
+++ b/layout/_partials/page/schedule.njk
@@ -1,6 +1,3 @@
-
{{- next_js('schedule.js', true) }}
diff --git a/layout/_partials/post/post-meta.njk b/layout/_partials/post/post-meta.njk
index fcd5f9a..846091a 100644
--- a/layout/_partials/post/post-meta.njk
+++ b/layout/_partials/post/post-meta.njk
@@ -72,7 +72,7 @@
{%- endif %}
{%- if not is_index and theme.busuanzi_count.enable and theme.busuanzi_count.post_views %}
-
+
diff --git a/layout/_scripts/index.njk b/layout/_scripts/index.njk
index 2251c1f..6aea29c 100644
--- a/layout/_scripts/index.njk
+++ b/layout/_scripts/index.njk
@@ -14,5 +14,5 @@
{{- next_js('bookmark.js') }}
{%- endif %}
{%- if theme.pjax %}
- {%- include 'pjax.njk' -%}
+ {{- next_js('pjax.js') }}
{%- endif %}
diff --git a/layout/_scripts/noscript.njk b/layout/_scripts/noscript.njk
deleted file mode 100644
index b1aa310..0000000
--- a/layout/_scripts/noscript.njk
+++ /dev/null
@@ -1,34 +0,0 @@
-
diff --git a/scripts/filters/minify.js b/scripts/filters/minify.js
index 22e8d1f..5249996 100644
--- a/scripts/filters/minify.js
+++ b/scripts/filters/minify.js
@@ -26,6 +26,14 @@ hexo.extend.filter.register('after_generate', () => {
hexo.route.remove('js/local-search.js');
}
+ if (!theme.pjax) {
+ hexo.route.remove('js/pjax.js');
+ }
+
+ if (theme.comments.style !== 'buttons') {
+ hexo.route.remove('js/comments-buttons.js');
+ }
+
if (theme.scheme === 'Pisces' || theme.scheme === 'Gemini') {
hexo.route.remove('js/schemes/muse.js');
}
diff --git a/scripts/helpers/next-config.js b/scripts/helpers/next-config.js
index 36819bb..733b729 100644
--- a/scripts/helpers/next-config.js
+++ b/scripts/helpers/next-config.js
@@ -5,7 +5,7 @@
const { parse } = require('url');
/**
- * Export theme config to js
+ * Export theme config
*/
hexo.extend.helper.register('next_config', function() {
const { config, theme, url_for, __ } = this;
@@ -45,8 +45,5 @@ hexo.extend.helper.register('next_config', function() {
exportConfig.path = url_for(config.search.path);
exportConfig.localsearch = theme.local_search;
}
- return ``;
+ return exportConfig;
});
diff --git a/scripts/tags/link-grid.js b/scripts/tags/link-grid.js
index b0398c9..1dfb800 100644
--- a/scripts/tags/link-grid.js
+++ b/scripts/tags/link-grid.js
@@ -9,7 +9,7 @@ module.exports = function([image = '/images/avatar.gif', delimiter = '|', commen
const item = line.split(delimiter).map(arg => arg.trim());
if (item[0][0] === comment) return '';
return `
-
+
`;
diff --git a/source/css/_common/components/post/post-header.styl b/source/css/_common/components/post/post-header.styl
index aaa7cd9..c4f3811 100644
--- a/source/css/_common/components/post/post-header.styl
+++ b/source/css/_common/components/post/post-header.styl
@@ -109,3 +109,9 @@
display: none;
}
}
+
+if (hexo-config('busuanzi_count.enable') and hexo-config('busuanzi_count.post_views')) {
+ #busuanzi_container_page_pv {
+ display: none;
+ }
+}
diff --git a/source/css/_common/outline/footer/index.styl b/source/css/_common/outline/footer/index.styl
index 79600c3..e78ed8b 100644
--- a/source/css/_common/outline/footer/index.styl
+++ b/source/css/_common/outline/footer/index.styl
@@ -74,3 +74,25 @@
animation: icon-animate 1.33s ease-in-out infinite;
}
}
+
+if (hexo-config('footer.beian.enable') && hexo-config('footer.beian.gongan_icon_url')) {
+ .beian img {
+ display: inline-block;
+ }
+}
+
+if (hexo-config('busuanzi_count.enable')) {
+ .busuanzi-count {
+ if (hexo-config('busuanzi_count.total_visitors')) {
+ #busuanzi_container_site_uv {
+ display: none;
+ }
+ }
+
+ if (hexo-config('busuanzi_count.total_views')) {
+ #busuanzi_container_site_pv {
+ display: none;
+ }
+ }
+ }
+}
diff --git a/source/css/_common/scaffolding/tags/link-grid.styl b/source/css/_common/scaffolding/tags/link-grid.styl
index 5fc7811..ef5033b 100644
--- a/source/css/_common/scaffolding/tags/link-grid.styl
+++ b/source/css/_common/scaffolding/tags/link-grid.styl
@@ -32,9 +32,6 @@
}
.link-grid-image {
- background-clip: content-box;
- background-origin: content-box;
- background-size: cover;
border: 1px solid $grey-lighter;
border-radius: 50%;
box-sizing: border-box;
diff --git a/source/css/noscript.styl b/source/css/noscript.styl
new file mode 100644
index 0000000..9b71ddb
--- /dev/null
+++ b/source/css/noscript.styl
@@ -0,0 +1,30 @@
+body { margin-top: 2rem; }
+
+.use-motion .menu-item,
+.use-motion .sidebar,
+.use-motion .post-block,
+.use-motion .pagination,
+.use-motion .comments,
+.use-motion .post-header,
+.use-motion .post-body,
+.use-motion .collection-header {
+ visibility: visible;
+}
+
+.use-motion .header,
+.use-motion .site-brand-container .toggle,
+.use-motion .footer { opacity: initial; }
+
+.use-motion .site-title,
+.use-motion .site-subtitle,
+.use-motion .custom-logo-image {
+ opacity: initial;
+ top: initial;
+}
+
+.use-motion .logo-line {
+ transform: scaleX(1);
+}
+
+.search-pop-overlay, .sidebar-nav { display: none; }
+.sidebar-panel { display: block; }
diff --git a/source/js/comments-buttons.js b/source/js/comments-buttons.js
new file mode 100644
index 0000000..505c21b
--- /dev/null
+++ b/source/js/comments-buttons.js
@@ -0,0 +1,25 @@
+/* global CONFIG */
+
+(function() {
+ const commentButton = document.querySelectorAll('.comment-button');
+ commentButton.forEach(element => {
+ const commentClass = element.classList[2];
+ element.addEventListener('click', () => {
+ commentButton.forEach(active => active.classList.toggle('active', active === element));
+ document.querySelectorAll('.comment-position').forEach(active => active.classList.toggle('active', active.classList.contains(commentClass)));
+ if (CONFIG.comments.storage) {
+ localStorage.setItem('comments_active', commentClass);
+ }
+ });
+ });
+ let { activeClass } = CONFIG.comments;
+ if (CONFIG.comments.storage) {
+ activeClass = localStorage.getItem('comments_active') || activeClass;
+ }
+ if (activeClass) {
+ const activeButton = document.querySelector(`.comment-button.${activeClass}`);
+ if (activeButton) {
+ activeButton.click();
+ }
+ }
+})();
diff --git a/source/js/comments.js b/source/js/comments.js
new file mode 100644
index 0000000..4045e8c
--- /dev/null
+++ b/source/js/comments.js
@@ -0,0 +1,21 @@
+/* global CONFIG */
+
+window.addEventListener('tabs:register', () => {
+ let { activeClass } = CONFIG.comments;
+ if (CONFIG.comments.storage) {
+ activeClass = localStorage.getItem('comments_active') || activeClass;
+ }
+ if (activeClass) {
+ const activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
+ if (activeTab) {
+ activeTab.click();
+ }
+ }
+});
+if (CONFIG.comments.storage) {
+ window.addEventListener('tabs:click', event => {
+ if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
+ const commentClass = event.target.classList[1];
+ localStorage.setItem('comments_active', commentClass);
+ });
+}
diff --git a/source/js/load-config.js b/source/js/load-config.js
new file mode 100644
index 0000000..d3c886a
--- /dev/null
+++ b/source/js/load-config.js
@@ -0,0 +1,15 @@
+if (!window.NexT) window.NexT = {};
+
+if (!window.CONFIG) {
+ window.CONFIG = JSON.parse(
+ document.querySelector('meta[name="hexo-config"]').content || '{}'
+ );
+}
+
+(() => {
+ document.querySelectorAll('meta[name^="hexo-config-"]')
+ .forEach(configMeta => {
+ const key = configMeta.name.slice('hexo-config-'.length);
+ window.CONFIG[key] = JSON.parse(configMeta.content || '{}');
+ });
+})();
diff --git a/layout/_scripts/pjax.njk b/source/js/pjax.js
similarity index 80%
rename from layout/_scripts/pjax.njk
rename to source/js/pjax.js
index f12bd60..6296e48 100644
--- a/layout/_scripts/pjax.njk
+++ b/source/js/pjax.js
@@ -1,17 +1,18 @@
-
diff --git a/test/tags/link-grid.js b/test/tags/link-grid.js
index 4dacb52..8faaf94 100644
--- a/test/tags/link-grid.js
+++ b/test/tags/link-grid.js
@@ -3,11 +3,11 @@
require('chai').should();
const result = `
-
+
-
+
`;
${item[0]}
${item[2] || item[1]}
Theme NexT
Stay Simple. Stay NexT.
Theme NexT
Stay Simple. Stay NexT.