ソースを参照

docs: Don't render the table of contents on the print page (#12340)

tags/v1.58.0rc1
Andrew Morgan 2年前
committed by GitHub
コミット
0922462fc7
この署名に対応する既知のキーがデータベースに存在しません GPGキーID: 4AEE18F83AFDEB23
2個のファイルの変更15行の追加0行の削除
  1. +1
    -0
      changelog.d/12340.doc
  2. +14
    -0
      docs/website_files/table-of-contents.js

+ 1
- 0
changelog.d/12340.doc ファイルの表示

@@ -0,0 +1 @@
Fix rendering of the documentation site when using the 'print' feature.

+ 14
- 0
docs/website_files/table-of-contents.js ファイルの表示

@@ -75,6 +75,20 @@ function setTocEntry() {
* Populate sidebar on load
*/
window.addEventListener('load', () => {
// Prevent rendering the table of contents of the "print book" page, as it
// will end up being rendered into the output (in a broken-looking way)

// Get the name of the current page (i.e. 'print.html')
const pageNameExtension = window.location.pathname.split('/').pop();

// Split off the extension (as '.../print' is also a valid page name), which
// should result in 'print'
const pageName = pageNameExtension.split('.')[0];
if (pageName === "print") {
// Don't render the table of contents on this page
return;
}

// Only create table of contents if there is more than one header on the page
if (headers.length <= 1) {
return;


読み込み中…
キャンセル
保存