Skip to content

Commit 4cbcb44

Browse files
committed
Cleanup the Javascript and CSS of our custom TOC
1 parent 72f915a commit 4cbcb44

File tree

2 files changed

+3
-15
lines changed

2 files changed

+3
-15
lines changed

src/doc/rustc/theme/pagetoc.css

-8
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,6 @@
1010
min-width: 50px;
1111
}
1212

13-
.previous {
14-
/*
15-
adjust the space between the left sidebar or the left side of the screen
16-
and the button that leads to the previous page
17-
*/
18-
margin-left: var(--page-padding);
19-
}
20-
2113
@media only screen {
2214
@media (max-width: 1179px) {
2315
.sidebar-hidden #sidetoc {

src/doc/rustc/theme/pagetoc.js

+3-7
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ function updatePageToc(elem = undefined) {
7171
}
7272
}
7373

74-
if (document.getElementById("sidetoc") === null) {
74+
if (document.getElementById("sidetoc") === null &&
75+
document.getElementsByClassName("header").length > 0) {
7576
// The sidetoc element doesn't exist yet, let's create it
7677

7778
// Create the empty sidetoc and pagetoc elements
@@ -80,16 +81,11 @@ if (document.getElementById("sidetoc") === null) {
8081
sidetoc.id = "sidetoc";
8182
pagetoc.id = "pagetoc";
8283
sidetoc.appendChild(pagetoc);
83-
84+
8485
// And append them to the current DOM
8586
const main = document.querySelector('main');
8687
main.insertBefore(sidetoc, main.firstChild);
87-
}
8888

89-
if (document.getElementsByClassName("header").length <= 1) {
90-
// There's one or less headings, we don't need a page table of contents
91-
document.getElementById("sidetoc").remove();
92-
} else {
9389
// Populate sidebar on load
9490
window.addEventListener("load", () => {
9591
for (const header of document.getElementsByClassName("header")) {

0 commit comments

Comments
 (0)