Skip to content

Commit f4d7218

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 44afd93 commit f4d7218

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
@@ -14,6 +14,7 @@
1414
"dependencies": {
1515
"@next/font": "^13.1.1",
1616
"bulma": "^0.8.2",
17+
"bulma-print": "^1.0.1",
1718
"classnames": "^2.3.1",
1819
"glob": "^7.1.7",
1920
"gray-matter": "^4.0.3",

styles/styles.scss

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

7676
@import "../node_modules/bulma/bulma.sass";
77+
@import "../node_modules/bulma-print/bulma-print";
7778

7879
// Darken colors
7980
@function darken($color) {
@@ -511,6 +512,24 @@ a:active {
511512
}
512513
}
513514

515+
@media print {
516+
.columns {
517+
display: block !important;
518+
margin: 0 !important;
519+
}
520+
.tk-content,
521+
.tk-markdown {
522+
width: 100% !important;
523+
padding: 0 !important;
524+
}
525+
.section {
526+
padding: 0 !important;
527+
}
528+
body {
529+
margin: revert !important;
530+
}
531+
}
532+
514533
.tk-docs {
515534
.tk-docs-nav {
516535
background-color: $light-gray;

0 commit comments

Comments
 (0)