Fix docs.rs header css selector, add min-width for TOC

This commit is contained in:
Folyd 2021-07-26 15:10:09 +08:00
parent 51f9c2f924
commit 2db365d90c
2 changed files with 3 additions and 2 deletions

View file

@ -63,6 +63,7 @@ div.nav-container form.landing-search-form-nav {
border-left: solid #bbb 1px;
padding-left: 10px;
max-width: 320px;
min-width: 120px;
}
.rse-doc-toc-item {

View file

@ -11,7 +11,7 @@ let installedVersion = undefined;
// Highlight the TOC
function highlight() {
let headers = Array.from(document.querySelectorAll("#main>.docblock>.section-header"))
let headers = Array.from(document.querySelectorAll("#main .docblock .section-header"))
.filter(header => ["H1", "H2", "H3"].includes(header.tagName));
const scrollHandler = entries => {
entries.forEach(entry => {
@ -36,7 +36,7 @@ function highlight() {
// Show TOC of docs.rs
document.addEventListener("DOMContentLoaded", () => {
let headers = Array.from(document.querySelectorAll("#main>.docblock>.section-header"))
let headers = Array.from(document.querySelectorAll("#main .docblock .section-header"))
.filter(header => ["H1", "H2", "H3"].includes(header.tagName));
if (!headers || headers.length < 3) {
// Don't show TOC if headers less than 3.