mirror of
https://github.com/next-theme/hexo-theme-next.git
synced 2026-01-17 18:22:33 +00:00
Some minor fixes
This commit is contained in:
parent
31298d003e
commit
46b4ad92b3
@ -793,7 +793,7 @@ tabs:
|
||||
# PDF tag
|
||||
# NexT will try to load pdf files natively, if failed, pdf.js will be used.
|
||||
# So, you have to install the dependency of pdf.js if you want to use pdf tag and make it available to all browsers.
|
||||
# See: https://github.com/next-theme/theme-next-pdf
|
||||
# Dependencies: https://github.com/next-theme/theme-next-pdf
|
||||
pdf:
|
||||
enable: false
|
||||
# Default height
|
||||
|
||||
@ -26,11 +26,7 @@ document.addEventListener('pjax:success', () => {
|
||||
}
|
||||
const hasTOC = document.querySelector('.post-toc');
|
||||
document.querySelector('.sidebar-inner').classList.toggle('sidebar-nav-active', hasTOC);
|
||||
if (hasTOC) {
|
||||
document.querySelector('.sidebar-nav-toc').click();
|
||||
} else {
|
||||
document.querySelector('.sidebar-nav-overview').click();
|
||||
}
|
||||
document.querySelector(hasTOC ? '.sidebar-nav-toc' : '.sidebar-nav-overview').click();
|
||||
NexT.utils.updateSidebarPosition();
|
||||
});
|
||||
</script>
|
||||
|
||||
@ -28,7 +28,13 @@ njkRenderer.compile = function(data) {
|
||||
const compiledTemplate = njkCompile(data);
|
||||
// Need a closure to keep the compiled template.
|
||||
return function(locals) {
|
||||
return compiledTemplate.render(locals);
|
||||
let result = '';
|
||||
try {
|
||||
result = compiledTemplate.render(locals);
|
||||
} catch (error) {
|
||||
hexo.log.error(error);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@ -62,8 +62,8 @@ NexT.motion.middleWares = {
|
||||
document.querySelectorAll('.menu-item').forEach(targets => {
|
||||
sequence.push({
|
||||
targets,
|
||||
begin : () => targets.classList.add('animated', 'fadeInDown'),
|
||||
deltaT: '-=200'
|
||||
complete: () => targets.classList.add('animated', 'fadeInDown'),
|
||||
deltaT : '-=200'
|
||||
});
|
||||
});
|
||||
|
||||
@ -89,8 +89,8 @@ NexT.motion.middleWares = {
|
||||
document.querySelectorAll(selector).forEach(targets => {
|
||||
sequence.push({
|
||||
targets,
|
||||
begin : () => targets.classList.add('animated', animation),
|
||||
deltaT: '-=100'
|
||||
complete: () => targets.classList.add('animated', animation),
|
||||
deltaT : '-=100'
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -109,8 +109,8 @@ NexT.motion.middleWares = {
|
||||
// Only for Pisces | Gemini.
|
||||
if (sidebarTransition && (CONFIG.scheme === 'Pisces' || CONFIG.scheme === 'Gemini')) {
|
||||
return [{
|
||||
targets: sidebar,
|
||||
begin : () => sidebar.classList.add('animated', sidebarTransition)
|
||||
targets : sidebar,
|
||||
complete: () => sidebar.classList.add('animated', sidebarTransition)
|
||||
}];
|
||||
}
|
||||
return [];
|
||||
|
||||
@ -66,6 +66,7 @@ NexT.utils = {
|
||||
document.querySelectorAll('figure.highlight').forEach(element => {
|
||||
element.querySelectorAll('.code .line span').forEach(span => {
|
||||
span.classList.forEach(name => {
|
||||
// https://caniuse.com/#feat=mdn-api_element_classlist_replace
|
||||
span.classList.remove(name);
|
||||
span.classList.add(`hljs-${name}`);
|
||||
});
|
||||
@ -138,8 +139,8 @@ NexT.utils = {
|
||||
if (backToTop || readingProgressBar) {
|
||||
const docHeight = document.querySelector('.container').offsetHeight;
|
||||
const winHeight = window.innerHeight;
|
||||
const contentVisibilityHeight = docHeight > winHeight ? docHeight - winHeight : document.body.scrollHeight - winHeight;
|
||||
const scrollPercent = Math.min(100 * window.scrollY / contentVisibilityHeight, 100);
|
||||
const contentHeight = docHeight > winHeight ? docHeight - winHeight : document.body.scrollHeight - winHeight;
|
||||
const scrollPercent = contentHeight > 0 ? Math.min(100 * window.scrollY / contentHeight, 100) : 0;
|
||||
if (backToTop) {
|
||||
backToTop.classList.toggle('back-to-top-on', Math.round(scrollPercent) >= 5);
|
||||
backToTop.querySelector('span').innerText = Math.round(scrollPercent) + '%';
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user