Skip to content

Commit c1290d7

Browse files
committed
Add print styles to remove navigation elements and excess whitespace
This makes it much easier to export the documentation to PDF or paper for offline reading.
1 parent 6128209 commit c1290d7

File tree

5 files changed

+35
-4
lines changed

5 files changed

+35
-4
lines changed

components/content.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import Link from "next/link";
66
function Footer({ next, prev, mdPath }) {
77
let edit = `https://github.com/tokio-rs/website/edit/master/content/${mdPath}`;
88
return (
9-
<div className="tk-doc-footer">
9+
<div className="tk-doc-footer is-hidden-print">
1010
<div className="level">
1111
<div className="level-left">
1212
<div className="level-item tk-prev">
@@ -98,7 +98,7 @@ function TableOfContents({ headings }) {
9898
}, [headings]);
9999

100100
return (
101-
<aside className="column is-one-third tk-content-summary">
101+
<aside className="column is-one-third tk-content-summary is-hidden-print">
102102
<ul className="tk-content-summary-menu">{list}</ul>
103103
</aside>
104104
);
@@ -134,7 +134,7 @@ export default function Content({
134134
return (
135135
<>
136136
<div className="columns is-marginless tk-docs">
137-
<div className="column is-one-quarter tk-docs-nav">
137+
<div className="column is-one-quarter tk-docs-nav is-hidden-print">
138138
<Menu href={href} menu={menu}>
139139
{isBlogRoute && (
140140
<div className="all-posts-link">

components/nav.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const Navigation: FC<{ blog: Blog }> = ({ blog }) => {
3939

4040
return (
4141
<nav
42-
className="navbar is-spaced"
42+
className="navbar is-spaced is-hidden-print"
4343
role="navigation"
4444
aria-label="main navigation"
4545
>

package-lock.json

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
},
1313
"dependencies": {
1414
"bulma": "^0.8.2",
15+
"bulma-print": "^1.0.1",
1516
"classnames": "2.5.1",
1617
"glob": "11.0.0",
1718
"gray-matter": "^4.0.3",

styles/styles.scss

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ $footer-background-color: black;
7979
$footer-color: white;
8080

8181
@import "../node_modules/bulma/bulma.sass";
82+
@import "../node_modules/bulma-print/bulma-print";
8283

8384
// Darken colors
8485
@function darken($color) {
@@ -516,6 +517,24 @@ a:active {
516517
}
517518
}
518519

520+
@media print {
521+
.columns {
522+
display: block !important;
523+
margin: 0 !important;
524+
}
525+
.tk-content,
526+
.tk-markdown {
527+
width: 100% !important;
528+
padding: 0 !important;
529+
}
530+
.section {
531+
padding: 0 !important;
532+
}
533+
body {
534+
margin: revert !important;
535+
}
536+
}
537+
519538
.tk-docs {
520539
.tk-docs-nav {
521540
background-color: $light-gray;

0 commit comments

Comments
 (0)