Skip to content

Commit 7b474f4

Browse files
author
yanlin.sky
committed
引入中文友好排版;ci: 升级 Hugo 到 0.148.2 并增加版本校验
- 新增 static/css/zh-typography.css:优化排版 - 在 layouts/partials/extend_head.html 全站引入上述样式
1 parent 4de6db8 commit 7b474f4

6 files changed

Lines changed: 152 additions & 4 deletions

File tree

.github/workflows/hugo.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,14 @@ jobs:
3232
build:
3333
runs-on: ubuntu-latest
3434
env:
35-
HUGO_VERSION: 0.127.0
35+
HUGO_VERSION: 0.148.2
3636
steps:
3737
- name: Install Hugo CLI
3838
run: |
3939
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
4040
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb
41+
- name: Verify Hugo version
42+
run: hugo version | tee /tmp/hugo-version.txt
4143
- name: Install Dart Sass
4244
run: sudo snap install dart-sass
4345
- name: Checkout

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[submodule "themes/PaperMod"]
22
path = themes/PaperMod
3-
url = git@github.com:adityatelange/hugo-PaperMod.git
3+
url = https://github.com/adityatelange/hugo-PaperMod.git

hugo.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ languageCode: zh-Hans
33
title: Sky's Blog
44
theme: ["PaperMod"]
55
copyright: "© 2024 [Sky's Blog](https://skyan.github.io)"
6-
paginate: 10
6+
pagination:
7+
pagerSize: 10
78

89
enableInlineShortcodes: true
910
enableRobotsTXT: true

layouts/partials/extend_head.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@
88
mermaid.initialize({ startOnLoad: true });
99
</script>
1010
{{ end }}
11+
12+
<link rel="stylesheet" href="/css/zh-typography.css" media="all" />

static/css/zh-typography.css

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
/* Chinese-friendly typography and UI refinements */
2+
3+
/* 1) Base font stack for Simplified Chinese with Latin fallbacks */
4+
html {
5+
-webkit-font-smoothing: antialiased;
6+
-moz-osx-font-smoothing: grayscale;
7+
text-rendering: optimizeLegibility;
8+
}
9+
10+
body {
11+
font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial,
12+
"PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Source Han Sans SC", "Microsoft YaHei", "WenQuanYi Micro Hei",
13+
"Noto Sans", sans-serif;
14+
line-height: 1.75; /* slightly taller for Chinese readability */
15+
letter-spacing: 0.1px; /* tiny spacing helps mixed CN/EN */
16+
}
17+
18+
/* 2) Page width and rhythm tweaks (PaperMod compatible) */
19+
.page,
20+
.post,
21+
.single,
22+
.content,
23+
.main {
24+
max-width: 860px; /* comfortable measure for mixed CN/EN */
25+
}
26+
27+
/* 3) Headings hierarchy with better CJK proportions */
28+
h1, h2, h3, h4, h5, h6 {
29+
font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Hiragino Sans GB",
30+
"Noto Sans CJK SC", "Source Han Sans SC", "Segoe UI", Roboto, Arial, sans-serif;
31+
line-height: 1.35;
32+
}
33+
34+
h1 { font-size: 2rem; margin: 1.2em 0 0.6em; }
35+
h2 { font-size: 1.65rem; margin: 1.1em 0 0.55em; }
36+
h3 { font-size: 1.35rem; margin: 1em 0 0.5em; }
37+
h4 { font-size: 1.15rem; margin: 0.9em 0 0.45em; }
38+
39+
/* 4) Paragraph spacing tuned for dense CJK */
40+
p, ul, ol {
41+
margin: 0.8em 0;
42+
}
43+
44+
/* 5) Better code presentation for CN articles */
45+
pre, code, kbd, samp {
46+
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
47+
}
48+
49+
pre code {
50+
font-size: 0.9rem;
51+
}
52+
53+
pre {
54+
line-height: 1.6;
55+
border-radius: 8px;
56+
}
57+
58+
code {
59+
padding: 0.1em 0.35em;
60+
border-radius: 4px;
61+
}
62+
63+
/* 6) Tables with improved readability */
64+
table {
65+
border-collapse: collapse;
66+
width: 100%;
67+
margin: 1em 0;
68+
}
69+
th, td {
70+
padding: 0.6em 0.8em;
71+
}
72+
thead th {
73+
border-bottom: 2px solid rgba(0,0,0,0.06);
74+
}
75+
tbody tr + tr {
76+
border-top: 1px solid rgba(0,0,0,0.06);
77+
}
78+
79+
/* 7) Quote style with CN tone */
80+
blockquote {
81+
border-left: 3px solid rgba(0,0,0,0.12);
82+
padding: 0.6em 1em;
83+
color: rgba(0,0,0,0.75);
84+
background: rgba(0,0,0,0.02);
85+
}
86+
87+
/* 8) Lists: better indentation and spacing for nested CN lists */
88+
ul ul, ol ol, ul ol, ol ul {
89+
margin-top: 0.4em;
90+
margin-bottom: 0.4em;
91+
}
92+
93+
/* 9) Links: subtle underline and hover color */
94+
a {
95+
text-decoration-thickness: 0.08em;
96+
text-underline-offset: 2px;
97+
}
98+
99+
a:hover {
100+
text-decoration-thickness: 0.12em;
101+
}
102+
103+
/* 10) Images: nicer figure captions spacing */
104+
figure {
105+
margin: 1.2em 0;
106+
}
107+
figcaption {
108+
margin-top: 0.4em;
109+
color: rgba(0,0,0,0.6);
110+
font-size: 0.95rem;
111+
}
112+
113+
/* 11) Home info bullets spacing (PaperMod) */
114+
.home-info ul {
115+
margin: 0.6em 0 0 1.25em;
116+
}
117+
118+
/* 12) KaTeX line-height alignment in mixed CN */
119+
.katex { line-height: 1.3; }
120+
121+
/* 13) Footnotes readability */
122+
.footnotes {
123+
font-size: 0.95rem;
124+
line-height: 1.6;
125+
}
126+
.footnotes hr { margin: 1.2em 0; }
127+
128+
/* 14) Search page input (PaperMod) */
129+
input#search-input {
130+
height: 2.4rem;
131+
padding: 0 0.8rem;
132+
border-radius: 8px;
133+
}
134+
135+
/* 15) Dark mode tuning for contrasts */
136+
@media (prefers-color-scheme: dark) {
137+
blockquote { color: rgba(255,255,255,0.8); background: rgba(255,255,255,0.04); border-left-color: rgba(255,255,255,0.18); }
138+
thead th { border-bottom-color: rgba(255,255,255,0.16); }
139+
tbody tr + tr { border-top-color: rgba(255,255,255,0.12); }
140+
figcaption { color: rgba(255,255,255,0.75); }
141+
}
142+
143+

0 commit comments

Comments
 (0)