diff --git a/packages/@vuepress/core/lib/client/components/OutboundLink.vue b/packages/@vuepress/core/lib/client/components/OutboundLink.vue index 06f8ba08b0..ab5e146368 100644 --- a/packages/@vuepress/core/lib/client/components/OutboundLink.vue +++ b/packages/@vuepress/core/lib/client/components/OutboundLink.vue @@ -28,4 +28,9 @@ position: relative; top: -1px; } +@media print { + .icon.outbound { + display: none; + } +} diff --git a/packages/@vuepress/theme-default/components/Navbar.vue b/packages/@vuepress/theme-default/components/Navbar.vue index f8dd49ca68..afad0cfd35 100644 --- a/packages/@vuepress/theme-default/components/Navbar.vue +++ b/packages/@vuepress/theme-default/components/Navbar.vue @@ -137,4 +137,8 @@ $navbar-horizontal-padding = 1.5rem overflow hidden white-space nowrap text-overflow ellipsis + +@media print + .navbar + display none diff --git a/packages/@vuepress/theme-default/components/PageEdit.vue b/packages/@vuepress/theme-default/components/PageEdit.vue index e1ac3ca096..ea1a5594e8 100644 --- a/packages/@vuepress/theme-default/components/PageEdit.vue +++ b/packages/@vuepress/theme-default/components/PageEdit.vue @@ -140,4 +140,7 @@ export default { float none text-align left +@media print + .page-edit + display none diff --git a/packages/@vuepress/theme-default/components/Sidebar.vue b/packages/@vuepress/theme-default/components/Sidebar.vue index e70e33367a..89c6612969 100644 --- a/packages/@vuepress/theme-default/components/Sidebar.vue +++ b/packages/@vuepress/theme-default/components/Sidebar.vue @@ -61,4 +61,8 @@ export default { top calc(1rem - 2px) & > .sidebar-links padding 1rem 0 + +@media print + .sidebar + display none diff --git a/packages/@vuepress/theme-default/styles/code.styl b/packages/@vuepress/theme-default/styles/code.styl index 9d3aa9a541..e3c4b75cae 100644 --- a/packages/@vuepress/theme-default/styles/code.styl +++ b/packages/@vuepress/theme-default/styles/code.styl @@ -57,7 +57,7 @@ div[class*="language-"] &.line-numbers-mode .highlight-lines .highlighted position relative - &:before + &::before content ' ' position absolute z-index 3 @@ -135,3 +135,19 @@ div[class~="language-php"]:before content "php" @import '~prismjs/themes/prism-tomorrow.css' + +@media print + {$contentClass} pre code, {$contentClass} pre[class*="language-"] code + color #000 + white-space pre-wrap + page-break-inside avoid + + code, pre, div[class*="language-"], div[class*="language-"] .highlight-lines .highlighted + background-color #fff + page-break-inside avoid + + div[class*="language-"].line-numbers-mode .highlight-lines + .highlighted::before + &::after + background-color #fff + page-break-inside avoid diff --git a/packages/@vuepress/theme-default/styles/custom-blocks.styl b/packages/@vuepress/theme-default/styles/custom-blocks.styl index 5b868166a4..578b256ed9 100644 --- a/packages/@vuepress/theme-default/styles/custom-blocks.styl +++ b/packages/@vuepress/theme-default/styles/custom-blocks.styl @@ -42,3 +42,9 @@ summary outline none cursor pointer + +@media print + .custom-block .custom-block-title + &.tip, &.warning, &.danger, &.details + background-color #fff + \ No newline at end of file diff --git a/packages/@vuepress/theme-default/styles/index.styl b/packages/@vuepress/theme-default/styles/index.styl index 976bfb0447..39d57166aa 100644 --- a/packages/@vuepress/theme-default/styles/index.styl +++ b/packages/@vuepress/theme-default/styles/index.styl @@ -199,3 +199,23 @@ th, td padding-left 0 @require 'mobile.styl' + +@media print + body + color #000 + + h1, h2, h3, h4, h5 + page-break-after avoid + page-break-before avoid + + img, table + page-break-inside avoid + + h2+p + page-break-before avoid + + a[href^="http://"]::after, a[href^="https://"]::after + content " [" attr(href) "] " + + .page + padding-left 0