feat(compatibility): improve compatibility for Hugo basic version (#352)

This commit is contained in:
Dillon
2020-05-13 00:45:19 +08:00
committed by GitHub
parent 6aa05a7f3e
commit 762a7e538d
26 changed files with 230 additions and 214 deletions

View File

@@ -419,7 +419,7 @@ class Theme {
const $tocLinkElements = $tocCore.querySelectorAll('a:first-child');
const $tocLiElements = $tocCore.getElementsByTagName('li');
const $headerLinkElements = document.getElementsByClassName('headerLink');
const headerIsFixed = this.config.headerMode.desktop !== 'normal';
const headerIsFixed = document.body.getAttribute('header-desktop') !== 'normal';
const headerHeight = document.getElementById('header-desktop').offsetHeight;
const TOP_SPACING = 20 + (headerIsFixed ? headerHeight : 0);
const minTocTop = $toc.offsetTop;
@@ -628,8 +628,8 @@ class Theme {
onScroll() {
const $headers = [];
if (this.config.headerMode.desktop === 'auto') $headers.push(document.getElementById('header-desktop'));
if (this.config.headerMode.mobile === 'auto') $headers.push(document.getElementById('header-mobile'));
if (document.body.getAttribute('header-desktop') === 'auto') $headers.push(document.getElementById('header-desktop'));
if (document.body.getAttribute('header-mobile') === 'auto') $headers.push(document.getElementById('header-mobile'));
if (document.getElementById('comments')) {
const $viewComments = document.getElementById('view-comments');
$viewComments.href = `#comments`;