mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-08-24 23:38:56 +00:00
🐛 Fix: toc display error without content header (#21)
This commit is contained in:
+1
-1
@@ -14,7 +14,7 @@
|
||||
- :bug: Fix: typeit print code error ([#19](https://github.com/Lruihao/FixIt/issues/19))
|
||||
- :bug: Fix: add scroll-margin to all anchors of page content ([#39](https://github.com/Lruihao/FixIt/issues/39))
|
||||
- :bug: Fix: pre element overflow error ([#29](https://github.com/Lruihao/FixIt/issues/29))
|
||||
- :bug: Fix: toc-auto display error ([#21](https://github.com/Lruihao/FixIt/issues/21))
|
||||
- :bug: Fix: toc display error without content header ([#21](https://github.com/Lruihao/FixIt/issues/21))
|
||||
- :fire: Feat: remove lib smooth-scroll ([#1](https://github.com/Lruihao/FixIt/issues/1))
|
||||
- :mag: Feat(SEO): optimize SEO meta ([#30](https://github.com/Lruihao/FixIt/issues/30))
|
||||
- :lipstick: Style: change scroll-behavior to smooth, header style, footer style etc.
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -11,7 +11,8 @@
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Auto TOC */ -}}
|
||||
{{- if ne $toc.enable false -}}
|
||||
{{- $tocEmpty := eq .TableOfContents `<nav id="TableOfContents"></nav>` -}}
|
||||
{{- if (ne $toc.enable false) | and (ne $tocEmpty true) -}}
|
||||
<div class="toc" id="toc-auto">
|
||||
<h2 class="toc-title">{{ T "contents" }}</h2>
|
||||
<div class="toc-content{{ if eq $toc.auto false }} always-active{{ end }}" id="toc-content-auto"></div>
|
||||
@@ -80,8 +81,8 @@
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Static TOC */ -}}
|
||||
{{- if ne $toc.enable false -}}
|
||||
<div class="details toc" id="toc-static" kept="{{ if $toc.keepStatic }}true{{ end }}">
|
||||
{{- if (ne $toc.enable false) | and (ne $tocEmpty true) -}}
|
||||
<div class="details toc" id="toc-static" kept="{{ if $toc.keepStatic }}true{{ else }}false{{ end }}">
|
||||
<div class="details-summary toc-title">
|
||||
<span>{{ T "contents" }}</span>
|
||||
<span><i class="details-icon fas fa-angle-right"></i></span>
|
||||
|
||||
+2
-6
@@ -399,12 +399,7 @@ class Theme {
|
||||
if ($tocCore === null){
|
||||
return;
|
||||
}
|
||||
const $toc = document.getElementById('toc-auto');
|
||||
if ($tocCore.innerText === ''){
|
||||
$toc.style.display = 'none';
|
||||
return;
|
||||
}
|
||||
if (document.getElementById('toc-static').getAttribute('kept') || this.util.isTocStatic()) {
|
||||
if (document.getElementById('toc-static').getAttribute('kept') === 'true' || this.util.isTocStatic()) {
|
||||
const $tocContentStatic = document.getElementById('toc-content-static');
|
||||
if ($tocCore.parentElement !== $tocContentStatic) {
|
||||
$tocCore.parentElement.removeChild($tocCore);
|
||||
@@ -417,6 +412,7 @@ class Theme {
|
||||
$tocCore.parentElement.removeChild($tocCore);
|
||||
$tocContentAuto.appendChild($tocCore);
|
||||
}
|
||||
const $toc = document.getElementById('toc-auto');
|
||||
const $page = document.getElementsByClassName('page')[0];
|
||||
const rect = $page.getBoundingClientRect();
|
||||
$toc.style.left = `${rect.left + rect.width + 20}px`;
|
||||
|
||||
Reference in New Issue
Block a user