mirror of
https://github.com/next-theme/hexo-theme-next.git
synced 2026-01-17 18:22:33 +00:00
Code style update
This commit is contained in:
parent
97035e6f56
commit
2ea722f0ed
@ -200,7 +200,7 @@ language_switcher: false
|
||||
|
||||
footer:
|
||||
# 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:
|
||||
@ -387,7 +387,7 @@ back2top:
|
||||
reading_progress:
|
||||
enable: false
|
||||
# Available values: left | right
|
||||
startAt: left
|
||||
start_at: left
|
||||
# Available values: top | bottom
|
||||
position: top
|
||||
reversed: false
|
||||
@ -560,11 +560,6 @@ quicklink:
|
||||
# Default (true) will attempt to use the fetch() API if supported (rather than link[rel=prefetch]).
|
||||
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
|
||||
|
||||
@ -28,7 +28,7 @@ class ViewInject {
|
||||
if (path.extname(name) === '') {
|
||||
name += defaultExtname;
|
||||
}
|
||||
this.raws.push({name, raw, args});
|
||||
this.raws.push({ name, raw, args });
|
||||
}
|
||||
file(name, file, ...args) {
|
||||
// Set default extname from file's extname
|
||||
|
||||
@ -10,7 +10,7 @@ hexo.extend.filter.register('theme_inject', injects => {
|
||||
const config = hexo.theme.config.changyan;
|
||||
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'));
|
||||
|
||||
|
||||
@ -14,7 +14,7 @@ hexo.extend.filter.register('theme_inject', injects => {
|
||||
<div class="comments" id="disqus_thread">
|
||||
<noscript>Please enable JavaScript to view the comments powered by Disqus.</noscript>
|
||||
</div>
|
||||
`, {}, {cache: true});
|
||||
`, {}, { cache: true });
|
||||
|
||||
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">
|
||||
<noscript>Please enable JavaScript to view the comments powered by Disqus.</noscript>
|
||||
</div>
|
||||
`, {}, {cache: true});
|
||||
`, {}, { cache: true });
|
||||
|
||||
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;
|
||||
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'));
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@ hexo.extend.filter.register('theme_inject', injects => {
|
||||
const theme = hexo.theme.config;
|
||||
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'));
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
width: var(--progress);
|
||||
}
|
||||
|
||||
if (hexo-config('reading_progress.startAt') == 'right') {
|
||||
if (hexo-config('reading_progress.start_at') == 'right') {
|
||||
right: 0;
|
||||
} else {
|
||||
left: 0;
|
||||
|
||||
@ -6,14 +6,14 @@ if (!window.NexT) window.NexT = {};
|
||||
const staticConfig = {};
|
||||
let variableConfig = {};
|
||||
|
||||
const parse = (text) => {
|
||||
const parse = text => {
|
||||
const jsonString = new DOMParser()
|
||||
.parseFromString(text, 'text/html').documentElement
|
||||
.textContent;
|
||||
return JSON.parse(jsonString || '{}');
|
||||
};
|
||||
|
||||
const update = (name) => {
|
||||
const update = name => {
|
||||
const targetEle = document.querySelector(`.${className}[data-name="${name}"]`);
|
||||
if (!targetEle) return;
|
||||
const parsedConfig = parse(targetEle.text);
|
||||
@ -48,7 +48,7 @@ if (!window.NexT) window.NexT = {};
|
||||
// When mixable
|
||||
if (typeof override === 'object' && typeof existing === 'object') {
|
||||
// Mix, proxy changes to the override.
|
||||
return new Proxy({...existing, ...override}, {
|
||||
return new Proxy({ ...existing, ...override }, {
|
||||
set(target, prop, value) {
|
||||
target[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) {
|
||||
NexT.utils.getScript(
|
||||
`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) {
|
||||
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') {
|
||||
window.MathJax = {
|
||||
tex: {
|
||||
inlineMath: {'[+]': [['$', '$']]},
|
||||
inlineMath: { '[+]': [['$', '$']] },
|
||||
tags : CONFIG.mathjax.tags
|
||||
},
|
||||
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', () => {
|
||||
if (!CONFIG.page.isPost) return;
|
||||
|
||||
const newWidgets = widgets.map(widget => ({...widget}));
|
||||
const newWidgets = widgets.map(widget => ({ ...widget }));
|
||||
|
||||
if (window.WPac) {
|
||||
WPac.init(newWidgets);
|
||||
|
||||
@ -23,7 +23,7 @@ firebase.initializeApp({
|
||||
});
|
||||
};
|
||||
|
||||
const appendCountTo = (el) => {
|
||||
const appendCountTo = el => {
|
||||
return count => {
|
||||
el.innerText = count;
|
||||
};
|
||||
|
||||
@ -2,19 +2,19 @@
|
||||
/* eslint-disable no-console */
|
||||
|
||||
(function() {
|
||||
const leancloudSelector = (url) => {
|
||||
const leancloudSelector = url => {
|
||||
url = encodeURI(url);
|
||||
return document.getElementById(url).querySelector('.leancloud-visitors-count');
|
||||
};
|
||||
|
||||
const addCount = (Counter) => {
|
||||
const addCount = Counter => {
|
||||
const visitors = document.querySelector('.leancloud_visitors');
|
||||
const url = decodeURI(visitors.id);
|
||||
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(({results}) => {
|
||||
.then(({ results }) => {
|
||||
if (results.length > 0) {
|
||||
const counter = results[0];
|
||||
leancloudSelector(url).innerText = counter.time + 1;
|
||||
@ -31,7 +31,7 @@
|
||||
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`.');
|
||||
} else {
|
||||
Counter('post', '/classes/Counter', {title, url, time: 1})
|
||||
Counter('post', '/classes/Counter', { title, url, time: 1 })
|
||||
.then(response => response.json())
|
||||
.then(() => {
|
||||
leancloudSelector(url).innerText = 1;
|
||||
@ -46,15 +46,15 @@
|
||||
});
|
||||
};
|
||||
|
||||
const showTime = (Counter) => {
|
||||
const showTime = Counter => {
|
||||
const visitors = document.querySelectorAll('.leancloud_visitors');
|
||||
const entries = [...visitors].map(element => {
|
||||
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(({results}) => {
|
||||
.then(({ results }) => {
|
||||
for (const url of entries) {
|
||||
const target = results.find(item => item.url === url);
|
||||
leancloudSelector(url).innerText = target ? target.time : 0;
|
||||
@ -65,8 +65,8 @@
|
||||
});
|
||||
};
|
||||
|
||||
const {app_id, app_key, server_url} = CONFIG.leancloud_visitors;
|
||||
const fetchData = (api_server) => {
|
||||
const { app_id, app_key, server_url } = CONFIG.leancloud_visitors;
|
||||
const fetchData = api_server => {
|
||||
const Counter = (method, url, data) => {
|
||||
return fetch(`${api_server}/1.1${url}`, {
|
||||
method,
|
||||
@ -94,7 +94,7 @@
|
||||
} else {
|
||||
fetch(`https://app-router.leancloud.cn/2/route?appId=${app_id}`)
|
||||
.then(response => response.json())
|
||||
.then(({api_server}) => {
|
||||
.then(({ 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({
|
||||
theme : CONFIG.mermaid.theme,
|
||||
logLevel : 3,
|
||||
flowchart: {curve: 'linear'},
|
||||
gantt : {axisFormat: '%m/%d/%Y'},
|
||||
sequence : {actorMargin: 50}
|
||||
flowchart: { curve: 'linear' },
|
||||
gantt : { axisFormat: '%m/%d/%Y' },
|
||||
sequence : { actorMargin: 50 }
|
||||
}, '.mermaid');
|
||||
});
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@ if (typeof DOMTokenList.prototype.replace !== 'function') {
|
||||
);
|
||||
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('readystatechange', onPageLoaded, {once: true});
|
||||
document.addEventListener('readystatechange', onPageLoaded, { once: true });
|
||||
} else {
|
||||
onPageLoaded();
|
||||
}
|
||||
@ -392,7 +392,7 @@ NexT.utils = {
|
||||
if (legacyCallback) {
|
||||
return this.loadComments(selector).then(legacyCallback);
|
||||
}
|
||||
return new Promise((resolve) => {
|
||||
return new Promise(resolve => {
|
||||
const element = document.querySelector(selector);
|
||||
if (!CONFIG.comments.lazyload || !element) {
|
||||
resolve();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user