Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 0922462

Browse files
docs: Don't render the table of contents on the print page (#12340)
1 parent 73d8ded commit 0922462

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

changelog.d/12340.doc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix rendering of the documentation site when using the 'print' feature.

docs/website_files/table-of-contents.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,20 @@ function setTocEntry() {
7575
* Populate sidebar on load
7676
*/
7777
window.addEventListener('load', () => {
78+
// Prevent rendering the table of contents of the "print book" page, as it
79+
// will end up being rendered into the output (in a broken-looking way)
80+
81+
// Get the name of the current page (i.e. 'print.html')
82+
const pageNameExtension = window.location.pathname.split('/').pop();
83+
84+
// Split off the extension (as '.../print' is also a valid page name), which
85+
// should result in 'print'
86+
const pageName = pageNameExtension.split('.')[0];
87+
if (pageName === "print") {
88+
// Don't render the table of contents on this page
89+
return;
90+
}
91+
7892
// Only create table of contents if there is more than one header on the page
7993
if (headers.length <= 1) {
8094
return;

0 commit comments

Comments
 (0)