Skip to content

Commit 25231e3

Browse files
Bluemangoozkqiang
authored andcommitted
✨ 增加打印样式
1 parent b67a247 commit 25231e3

File tree

6 files changed

+55
-7
lines changed

6 files changed

+55
-7
lines changed

layout/_partials/post/copyright.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
<% if (['BY', 'BY-SA', 'BY-ND', 'BY-NC', 'BY-NC-SA', 'BY-NC-ND'].indexOf(license) !== -1) { %>
4141
<% var items = license.split('-') %>
4242
<% for (var idx = 0; idx < items.length; idx++) { %>
43-
<a target="_blank" href="https://creativecommons.org/licenses/<%= license.toLowerCase() %>/4.0/">
43+
<a class="print-no-link" target="_blank" href="https://creativecommons.org/licenses/<%= license.toLowerCase() %>/4.0/">
4444
<span class="hint--top hint--rounded" aria-label="<%- __('post.copyright.' + items[idx]) %>">
4545
<i class="iconfont icon-<%= items[idx].toLowerCase() %>"></i>
4646
</span>

layout/_partials/post/meta-bottom.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<div class="post-meta">
1010
<i class="iconfont icon-tags"></i>
1111
<% page.tags.each(function(tag) { %>
12-
<a href="<%= url_for(tag.path) %>">#<%- tag.name %></a>
12+
<a href="<%= url_for(tag.path) %>" class="print-no-link">#<%- tag.name %></a>
1313
<% }) %>
1414
</div>
1515
<% } %>

layout/post.ejs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ page.banner_mask_alpha = page.banner_mask_alpha || theme.post.banner_mask_alpha
1414
<div class="container nopadding-x-md" id="board-ctn">
1515
<div id="board">
1616
<article class="post-content mx-auto">
17-
<!-- SEO header -->
18-
<h1 style="display: none"><%= page.subtitle || page.title %></h1>
17+
<h1 id="seo-header"><%= page.subtitle || page.title %></h1>
1918
<% if (theme.post.updated.enable && theme.post.updated && compare_date(page.date, page.updated)) { %>
2019
<p class="note note-<%= theme.post.updated.note_class || 'info' %>">
2120
<% if (theme.post.updated.relative) { %>

source/css/_pages/_base/color-schema.styl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,13 @@ dark-colors()
5959
transition background-color .2s ease-in-out
6060

6161
if (hexo-config("dark_mode.enable"))
62-
@media (prefers-color-scheme: dark)
62+
@media not print and (prefers-color-scheme: dark)
6363
:root
6464
--color-mode "dark"
6565

6666
:root:not([data-user-color-scheme])
6767
dark-colors()
6868

69-
[data-user-color-scheme="dark"]
70-
dark-colors()
69+
@media not print
70+
[data-user-color-scheme="dark"]
71+
dark-colors()

source/css/_pages/_base/print.styl

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
@media print
2+
header, footer, .side-col, #scroll-top-button, .post-prevnext, #comments
3+
display none !important
4+
5+
.markdown-body
6+
a:not([href^='#']):not([href^='javascript:']):not(.print-no-link)::after
7+
content ' (' attr(href) ')'
8+
font-size 0.8rem
9+
color var(--post-text-color)
10+
opacity 0.8
11+
12+
& > h1, h2
13+
border-bottom-color transparent !important
14+
15+
& > h1, h2, h3, h4, h5, h6
16+
margin-top 1.25em !important
17+
margin-bottom 0.25em !important
18+
19+
[data-anchorjs-icon]::after
20+
display none
21+
22+
figure.highlight
23+
table, tbody, tr, td.code, td.code pre
24+
width 100% !important
25+
display block !important
26+
27+
pre > code
28+
white-space pre-wrap
29+
30+
.gutter, .code-widget
31+
display none !important
32+
33+
.post-metas a
34+
text-decoration none
35+
36+
@media not print
37+
#seo-header
38+
display none

source/css/_pages/_post/post-page.styl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,16 @@
125125
-webkit-transform translateX(0)
126126
transform translateX(0)
127127

128+
#seo-header
129+
color var(--post-heading-color)
130+
font-weight bold
131+
margin-top 0.5em
132+
margin-bottom 0.75em
133+
border-bottom-color var(--line-color)
134+
border-bottom-style solid
135+
border-bottom-width 2px
136+
line-height 1.5
137+
128138
.custom, #comments
129139
margin-top 2rem
130140

0 commit comments

Comments
 (0)