mirror of
https://github.com/next-theme/hexo-theme-next.git
synced 2026-01-19 18:42:34 +00:00
Code style update
This commit is contained in:
parent
97035e6f56
commit
2ea722f0ed
@ -200,7 +200,7 @@ language_switcher: false
|
|||||||
|
|
||||||
footer:
|
footer:
|
||||||
# Specify the year when the site was setup. If not defined, current year will be used.
|
# Specify the year when the site was setup. If not defined, current year will be used.
|
||||||
#since: 2020
|
#since: 2021
|
||||||
|
|
||||||
# Icon between year and copyright info.
|
# Icon between year and copyright info.
|
||||||
icon:
|
icon:
|
||||||
@ -387,7 +387,7 @@ back2top:
|
|||||||
reading_progress:
|
reading_progress:
|
||||||
enable: false
|
enable: false
|
||||||
# Available values: left | right
|
# Available values: left | right
|
||||||
startAt: left
|
start_at: left
|
||||||
# Available values: top | bottom
|
# Available values: top | bottom
|
||||||
position: top
|
position: top
|
||||||
reversed: false
|
reversed: false
|
||||||
@ -560,11 +560,6 @@ quicklink:
|
|||||||
# Default (true) will attempt to use the fetch() API if supported (rather than link[rel=prefetch]).
|
# Default (true) will attempt to use the fetch() API if supported (rather than link[rel=prefetch]).
|
||||||
priority: true
|
priority: true
|
||||||
|
|
||||||
# For more flexibility you can add some patterns (RegExp, Function, or Array) to ignores.
|
|
||||||
# See: https://github.com/GoogleChromeLabs/quicklink#custom-ignore-patterns
|
|
||||||
# This option is deprecated. Use `CONFIG.quicklink.ignores` in your custom scripts instead.
|
|
||||||
ignores:
|
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------
|
# ---------------------------------------------------------------
|
||||||
# Comments Settings
|
# Comments Settings
|
||||||
|
|||||||
@ -28,7 +28,7 @@ class ViewInject {
|
|||||||
if (path.extname(name) === '') {
|
if (path.extname(name) === '') {
|
||||||
name += defaultExtname;
|
name += defaultExtname;
|
||||||
}
|
}
|
||||||
this.raws.push({name, raw, args});
|
this.raws.push({ name, raw, args });
|
||||||
}
|
}
|
||||||
file(name, file, ...args) {
|
file(name, file, ...args) {
|
||||||
// Set default extname from file's extname
|
// Set default extname from file's extname
|
||||||
|
|||||||
@ -10,7 +10,7 @@ hexo.extend.filter.register('theme_inject', injects => {
|
|||||||
const config = hexo.theme.config.changyan;
|
const config = hexo.theme.config.changyan;
|
||||||
if (!config.enable || !config.appid || !config.appkey) return;
|
if (!config.enable || !config.appid || !config.appkey) return;
|
||||||
|
|
||||||
injects.comment.raw('changyan', '<div class="comments" id="SOHUCS"></div>', {}, {cache: true});
|
injects.comment.raw('changyan', '<div class="comments" id="SOHUCS"></div>', {}, { cache: true });
|
||||||
|
|
||||||
injects.bodyEnd.file('changyan', path.join(hexo.theme_dir, 'layout/_third-party/comments/changyan.njk'));
|
injects.bodyEnd.file('changyan', path.join(hexo.theme_dir, 'layout/_third-party/comments/changyan.njk'));
|
||||||
|
|
||||||
|
|||||||
@ -14,7 +14,7 @@ hexo.extend.filter.register('theme_inject', injects => {
|
|||||||
<div class="comments" id="disqus_thread">
|
<div class="comments" id="disqus_thread">
|
||||||
<noscript>Please enable JavaScript to view the comments powered by Disqus.</noscript>
|
<noscript>Please enable JavaScript to view the comments powered by Disqus.</noscript>
|
||||||
</div>
|
</div>
|
||||||
`, {}, {cache: true});
|
`, {}, { cache: true });
|
||||||
|
|
||||||
injects.bodyEnd.file('disqus', path.join(hexo.theme_dir, 'layout/_third-party/comments/disqus.njk'));
|
injects.bodyEnd.file('disqus', path.join(hexo.theme_dir, 'layout/_third-party/comments/disqus.njk'));
|
||||||
|
|
||||||
|
|||||||
@ -13,7 +13,7 @@ hexo.extend.filter.register('theme_inject', injects => {
|
|||||||
<div class="comments" id="disqus_thread">
|
<div class="comments" id="disqus_thread">
|
||||||
<noscript>Please enable JavaScript to view the comments powered by Disqus.</noscript>
|
<noscript>Please enable JavaScript to view the comments powered by Disqus.</noscript>
|
||||||
</div>
|
</div>
|
||||||
`, {}, {cache: true});
|
`, {}, { cache: true });
|
||||||
|
|
||||||
injects.bodyEnd.file('disqusjs', path.join(hexo.theme_dir, 'layout/_third-party/comments/disqusjs.njk'));
|
injects.bodyEnd.file('disqusjs', path.join(hexo.theme_dir, 'layout/_third-party/comments/disqusjs.njk'));
|
||||||
|
|
||||||
|
|||||||
@ -9,7 +9,7 @@ hexo.extend.filter.register('theme_inject', injects => {
|
|||||||
const theme = hexo.theme.config;
|
const theme = hexo.theme.config;
|
||||||
if (!theme.gitalk.enable) return;
|
if (!theme.gitalk.enable) return;
|
||||||
|
|
||||||
injects.comment.raw('gitalk', '<div class="comments gitalk-container"></div>', {}, {cache: true});
|
injects.comment.raw('gitalk', '<div class="comments gitalk-container"></div>', {}, { cache: true });
|
||||||
|
|
||||||
injects.bodyEnd.file('gitalk', path.join(hexo.theme_dir, 'layout/_third-party/comments/gitalk.njk'));
|
injects.bodyEnd.file('gitalk', path.join(hexo.theme_dir, 'layout/_third-party/comments/gitalk.njk'));
|
||||||
|
|
||||||
|
|||||||
@ -9,7 +9,7 @@ hexo.extend.filter.register('theme_inject', injects => {
|
|||||||
const theme = hexo.theme.config;
|
const theme = hexo.theme.config;
|
||||||
if (!theme.livere_uid) return;
|
if (!theme.livere_uid) return;
|
||||||
|
|
||||||
injects.comment.raw('livere', '<div class="comments" id="lv-container" data-id="city" data-uid="{{ theme.livere_uid }}"></div>', {}, {cache: true});
|
injects.comment.raw('livere', '<div class="comments" id="lv-container" data-id="city" data-uid="{{ theme.livere_uid }}"></div>', {}, { cache: true });
|
||||||
|
|
||||||
injects.bodyEnd.file('livere', path.join(hexo.theme_dir, 'layout/_third-party/comments/livere.njk'));
|
injects.bodyEnd.file('livere', path.join(hexo.theme_dir, 'layout/_third-party/comments/livere.njk'));
|
||||||
|
|
||||||
|
|||||||
@ -11,7 +11,7 @@
|
|||||||
width: var(--progress);
|
width: var(--progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hexo-config('reading_progress.startAt') == 'right') {
|
if (hexo-config('reading_progress.start_at') == 'right') {
|
||||||
right: 0;
|
right: 0;
|
||||||
} else {
|
} else {
|
||||||
left: 0;
|
left: 0;
|
||||||
|
|||||||
@ -6,14 +6,14 @@ if (!window.NexT) window.NexT = {};
|
|||||||
const staticConfig = {};
|
const staticConfig = {};
|
||||||
let variableConfig = {};
|
let variableConfig = {};
|
||||||
|
|
||||||
const parse = (text) => {
|
const parse = text => {
|
||||||
const jsonString = new DOMParser()
|
const jsonString = new DOMParser()
|
||||||
.parseFromString(text, 'text/html').documentElement
|
.parseFromString(text, 'text/html').documentElement
|
||||||
.textContent;
|
.textContent;
|
||||||
return JSON.parse(jsonString || '{}');
|
return JSON.parse(jsonString || '{}');
|
||||||
};
|
};
|
||||||
|
|
||||||
const update = (name) => {
|
const update = name => {
|
||||||
const targetEle = document.querySelector(`.${className}[data-name="${name}"]`);
|
const targetEle = document.querySelector(`.${className}[data-name="${name}"]`);
|
||||||
if (!targetEle) return;
|
if (!targetEle) return;
|
||||||
const parsedConfig = parse(targetEle.text);
|
const parsedConfig = parse(targetEle.text);
|
||||||
@ -48,7 +48,7 @@ if (!window.NexT) window.NexT = {};
|
|||||||
// When mixable
|
// When mixable
|
||||||
if (typeof override === 'object' && typeof existing === 'object') {
|
if (typeof override === 'object' && typeof existing === 'object') {
|
||||||
// Mix, proxy changes to the override.
|
// Mix, proxy changes to the override.
|
||||||
return new Proxy({...existing, ...override}, {
|
return new Proxy({ ...existing, ...override }, {
|
||||||
set(target, prop, value) {
|
set(target, prop, value) {
|
||||||
target[prop] = value;
|
target[prop] = value;
|
||||||
override[prop] = value;
|
override[prop] = value;
|
||||||
|
|||||||
2
source/js/third-party/comments/changyan.js
vendored
2
source/js/third-party/comments/changyan.js
vendored
@ -4,7 +4,7 @@ document.addEventListener('page:loaded', () => {
|
|||||||
if (CONFIG.page.isHome) {
|
if (CONFIG.page.isHome) {
|
||||||
NexT.utils.getScript(
|
NexT.utils.getScript(
|
||||||
`https://changyan.sohu.com/upload/plugins/plugins.list.count.js?clientId=${CONFIG.changyan.appid}`,
|
`https://changyan.sohu.com/upload/plugins/plugins.list.count.js?clientId=${CONFIG.changyan.appid}`,
|
||||||
{ attributes: {id: 'cy_cmt_num' } }
|
{ attributes: { id: 'cy_cmt_num' } }
|
||||||
);
|
);
|
||||||
} else if (CONFIG.page.comments) {
|
} else if (CONFIG.page.comments) {
|
||||||
NexT.utils.loadComments('#SOHUCS')
|
NexT.utils.loadComments('#SOHUCS')
|
||||||
|
|||||||
2
source/js/third-party/math/mathjax.js
vendored
2
source/js/third-party/math/mathjax.js
vendored
@ -6,7 +6,7 @@ document.addEventListener('page:loaded', () => {
|
|||||||
if (typeof MathJax === 'undefined') {
|
if (typeof MathJax === 'undefined') {
|
||||||
window.MathJax = {
|
window.MathJax = {
|
||||||
tex: {
|
tex: {
|
||||||
inlineMath: {'[+]': [['$', '$']]},
|
inlineMath: { '[+]': [['$', '$']] },
|
||||||
tags : CONFIG.mathjax.tags
|
tags : CONFIG.mathjax.tags
|
||||||
},
|
},
|
||||||
options: {
|
options: {
|
||||||
|
|||||||
2
source/js/third-party/rating.js
vendored
2
source/js/third-party/rating.js
vendored
@ -11,7 +11,7 @@
|
|||||||
document.addEventListener('page:loaded', () => {
|
document.addEventListener('page:loaded', () => {
|
||||||
if (!CONFIG.page.isPost) return;
|
if (!CONFIG.page.isPost) return;
|
||||||
|
|
||||||
const newWidgets = widgets.map(widget => ({...widget}));
|
const newWidgets = widgets.map(widget => ({ ...widget }));
|
||||||
|
|
||||||
if (window.WPac) {
|
if (window.WPac) {
|
||||||
WPac.init(newWidgets);
|
WPac.init(newWidgets);
|
||||||
|
|||||||
@ -23,7 +23,7 @@ firebase.initializeApp({
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const appendCountTo = (el) => {
|
const appendCountTo = el => {
|
||||||
return count => {
|
return count => {
|
||||||
el.innerText = count;
|
el.innerText = count;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -2,19 +2,19 @@
|
|||||||
/* eslint-disable no-console */
|
/* eslint-disable no-console */
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
const leancloudSelector = (url) => {
|
const leancloudSelector = url => {
|
||||||
url = encodeURI(url);
|
url = encodeURI(url);
|
||||||
return document.getElementById(url).querySelector('.leancloud-visitors-count');
|
return document.getElementById(url).querySelector('.leancloud-visitors-count');
|
||||||
};
|
};
|
||||||
|
|
||||||
const addCount = (Counter) => {
|
const addCount = Counter => {
|
||||||
const visitors = document.querySelector('.leancloud_visitors');
|
const visitors = document.querySelector('.leancloud_visitors');
|
||||||
const url = decodeURI(visitors.id);
|
const url = decodeURI(visitors.id);
|
||||||
const title = visitors.dataset.flagTitle;
|
const title = visitors.dataset.flagTitle;
|
||||||
|
|
||||||
Counter('get', `/classes/Counter?where=${encodeURIComponent(JSON.stringify({url}))}`)
|
Counter('get', `/classes/Counter?where=${encodeURIComponent(JSON.stringify({ url }))}`)
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(({results}) => {
|
.then(({ results }) => {
|
||||||
if (results.length > 0) {
|
if (results.length > 0) {
|
||||||
const counter = results[0];
|
const counter = results[0];
|
||||||
leancloudSelector(url).innerText = counter.time + 1;
|
leancloudSelector(url).innerText = counter.time + 1;
|
||||||
@ -31,7 +31,7 @@
|
|||||||
leancloudSelector(url).innerText = 'Counter not initialized! More info at console err msg.';
|
leancloudSelector(url).innerText = 'Counter not initialized! More info at console err msg.';
|
||||||
console.error('ATTENTION! LeanCloud counter has security bug, see how to solve it here: https://github.com/theme-next/hexo-leancloud-counter-security. \n However, you can still use LeanCloud without security, by setting `security` option to `false`.');
|
console.error('ATTENTION! LeanCloud counter has security bug, see how to solve it here: https://github.com/theme-next/hexo-leancloud-counter-security. \n However, you can still use LeanCloud without security, by setting `security` option to `false`.');
|
||||||
} else {
|
} else {
|
||||||
Counter('post', '/classes/Counter', {title, url, time: 1})
|
Counter('post', '/classes/Counter', { title, url, time: 1 })
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(() => {
|
.then(() => {
|
||||||
leancloudSelector(url).innerText = 1;
|
leancloudSelector(url).innerText = 1;
|
||||||
@ -46,15 +46,15 @@
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const showTime = (Counter) => {
|
const showTime = Counter => {
|
||||||
const visitors = document.querySelectorAll('.leancloud_visitors');
|
const visitors = document.querySelectorAll('.leancloud_visitors');
|
||||||
const entries = [...visitors].map(element => {
|
const entries = [...visitors].map(element => {
|
||||||
return decodeURI(element.id);
|
return decodeURI(element.id);
|
||||||
});
|
});
|
||||||
|
|
||||||
Counter('get', `/classes/Counter?where=${encodeURIComponent(JSON.stringify({url: {'$in': entries}}))}`)
|
Counter('get', `/classes/Counter?where=${encodeURIComponent(JSON.stringify({ url: { '$in': entries } }))}`)
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(({results}) => {
|
.then(({ results }) => {
|
||||||
for (const url of entries) {
|
for (const url of entries) {
|
||||||
const target = results.find(item => item.url === url);
|
const target = results.find(item => item.url === url);
|
||||||
leancloudSelector(url).innerText = target ? target.time : 0;
|
leancloudSelector(url).innerText = target ? target.time : 0;
|
||||||
@ -65,8 +65,8 @@
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const {app_id, app_key, server_url} = CONFIG.leancloud_visitors;
|
const { app_id, app_key, server_url } = CONFIG.leancloud_visitors;
|
||||||
const fetchData = (api_server) => {
|
const fetchData = api_server => {
|
||||||
const Counter = (method, url, data) => {
|
const Counter = (method, url, data) => {
|
||||||
return fetch(`${api_server}/1.1${url}`, {
|
return fetch(`${api_server}/1.1${url}`, {
|
||||||
method,
|
method,
|
||||||
@ -94,7 +94,7 @@
|
|||||||
} else {
|
} else {
|
||||||
fetch(`https://app-router.leancloud.cn/2/route?appId=${app_id}`)
|
fetch(`https://app-router.leancloud.cn/2/route?appId=${app_id}`)
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(({api_server}) => {
|
.then(({ api_server }) => {
|
||||||
fetchData(`https://${api_server}`);
|
fetchData(`https://${api_server}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
6
source/js/third-party/tags/mermaid.js
vendored
6
source/js/third-party/tags/mermaid.js
vendored
@ -16,9 +16,9 @@ document.addEventListener('page:loaded', () => {
|
|||||||
mermaid.init({
|
mermaid.init({
|
||||||
theme : CONFIG.mermaid.theme,
|
theme : CONFIG.mermaid.theme,
|
||||||
logLevel : 3,
|
logLevel : 3,
|
||||||
flowchart: {curve: 'linear'},
|
flowchart: { curve: 'linear' },
|
||||||
gantt : {axisFormat: '%m/%d/%Y'},
|
gantt : { axisFormat: '%m/%d/%Y' },
|
||||||
sequence : {actorMargin: 50}
|
sequence : { actorMargin: 50 }
|
||||||
}, '.mermaid');
|
}, '.mermaid');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,7 +22,7 @@ if (typeof DOMTokenList.prototype.replace !== 'function') {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (document.readyState === 'loading') {
|
if (document.readyState === 'loading') {
|
||||||
document.addEventListener('readystatechange', onPageLoaded, {once: true});
|
document.addEventListener('readystatechange', onPageLoaded, { once: true });
|
||||||
} else {
|
} else {
|
||||||
onPageLoaded();
|
onPageLoaded();
|
||||||
}
|
}
|
||||||
@ -392,7 +392,7 @@ NexT.utils = {
|
|||||||
if (legacyCallback) {
|
if (legacyCallback) {
|
||||||
return this.loadComments(selector).then(legacyCallback);
|
return this.loadComments(selector).then(legacyCallback);
|
||||||
}
|
}
|
||||||
return new Promise((resolve) => {
|
return new Promise(resolve => {
|
||||||
const element = document.querySelector(selector);
|
const element = document.querySelector(selector);
|
||||||
if (!CONFIG.comments.lazyload || !element) {
|
if (!CONFIG.comments.lazyload || !element) {
|
||||||
resolve();
|
resolve();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user