Skip to content

Commit d45b306

Browse files
committed
Add print button on all pages
1 parent 4bcccb8 commit d45b306

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

docs/css/custom.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,9 @@
2525
margin: 0.5in 0.1in 0.5in 0.1in; /* Adjust margins for header/footer space */
2626
}
2727

28+
29+
/* Hide the print button when printing */
30+
.print-button {
31+
display: none;
32+
}
2833
}

docs/js/extra.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
document.addEventListener('DOMContentLoaded', function () {
2+
const header = document.querySelector('main h1'); // Insert below the main title
3+
if (header) {
4+
const printButton = document.createElement('button');
5+
printButton.textContent = '🖨️ Print this page';
6+
printButton.className = 'print-button';
7+
printButton.addEventListener('click', function () {
8+
window.print();
9+
});
10+
header.after(printButton); // Add the button after the title
11+
}
12+
});

mkdocs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ markdown_extensions:
9696
- pymdownx.superfences
9797
extra_css:
9898
- css/custom.css
99+
extra_javascript:
100+
- js/extra.js
99101
copyright: >
100102
Copyright © 2024 Nomana-IT –
101103
<a href="#__consent">Change cookie settings</a>

0 commit comments

Comments
 (0)