Skip to content

Commit fa03cfd

Browse files
committed
新增可切换的 Resume Markdown 阅读排版
1 parent e2512fd commit fa03cfd

14 files changed

Lines changed: 594 additions & 19 deletions

‎README.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,9 @@
1717
`npm run dev` / `npm run build`(经 `gen:data`)会幂等压缩 `posts/`、`shuoshuo/`、`Summary/` 旁路 jpg/png/webp;已记录在 `config/image-compress-manifest.json` 的文件不会重压。也可单独执行 `npm run compress:images`。
1818

1919
浏览器工具页:导航「更多 → 图片压缩」(`/image-compress`),支持本地上传下载,并展示站内已压缩配图收益。
20+
21+
## Resume 阅读排版
22+
23+
首页及全站导航栏的外观/氛围按钮旁新增「排版」开关。开启后,Markdown 正文采用 Resume 的 Lapis CV Serif 风格:思源黑体正文、思源宋体标题、JetBrains Mono 英文与代码、1.8 倍行高、蓝色章节标题及细分隔线。字号与段落留白按博客长文适配,同时支持浅色、深色和专注阅读模式。
24+
25+
默认使用原样式,关闭开关即可恢复。选择保存在本机浏览器中,跨页面和刷新后继续生效;存储不可用时仍可在当前会话切换。字体随项目提供,WOFF2 文件仅在新排版启用时按需加载,首次开启可能需要等待字体下载。字体来源与许可见 `src/assets/resume-fonts/NOTICE.md`。
90.2 KB
Binary file not shown.

‎src/assets/resume-fonts/NOTICE.md‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Resume 排版字体
2+
3+
来源:Resume/lapis-cv/fonts。原始 TTF 无损转换为 WOFF2,保留完整字符集;仅开启新排版时加载。
4+
5+
## JetBrainsMono-Regular.woff2
6+
7+
Copyright 2020 The JetBrains Mono Project Authors (https://github.com/JetBrains/JetBrainsMono)
8+
This Font Software is licensed under the SIL Open Font License, Version 1.1. This license is available with a FAQ at: https://scripts.sil.org/OFL
9+
https://scripts.sil.org/OFL
10+
11+
## SourceHanSerifCN-Bold.woff2
12+
13+
© 2017-2024 Adobe (http://www.adobe.com/), with Reserved Font Name 'Source'.
14+
This Font Software is licensed under the SIL Open Font License, Version 1.1. This Font Software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the SIL Open Font License for the specific language, permissions and limitations governing your use of this Font Software.
15+
http://scripts.sil.org/OFL
16+
17+
## SourceHanSansCN-Regular.woff2
18+
19+
© 2014-2021 Adobe (http://www.adobe.com/), with Reserved Font Name 'Source'.
20+
This Font Software is licensed under the SIL Open Font License, Version 1.1. This Font Software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the SIL Open Font License for the specific language, permissions and limitations governing your use of this Font Software.
21+
http://scripts.sil.org/OFL
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
Copyright 2020 The JetBrains Mono Project Authors (https://github.com/JetBrains/JetBrainsMono)
2+
3+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
4+
This license is copied below, and is also available with a FAQ at:
5+
https://openfontlicense.org
6+
7+
8+
-----------------------------------------------------------
9+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10+
-----------------------------------------------------------
11+
12+
PREAMBLE
13+
The goals of the Open Font License (OFL) are to stimulate worldwide
14+
development of collaborative font projects, to support the font creation
15+
efforts of academic and linguistic communities, and to provide a free and
16+
open framework in which fonts may be shared and improved in partnership
17+
with others.
18+
19+
The OFL allows the licensed fonts to be used, studied, modified and
20+
redistributed freely as long as they are not sold by themselves. The
21+
fonts, including any derivative works, can be bundled, embedded,
22+
redistributed and/or sold with any software provided that any reserved
23+
names are not used by derivative works. The fonts and derivatives,
24+
however, cannot be released under any other type of license. The
25+
requirement for fonts to remain under this license does not apply
26+
to any document created using the fonts or their derivatives.
27+
28+
DEFINITIONS
29+
"Font Software" refers to the set of files released by the Copyright
30+
Holder(s) under this license and clearly marked as such. This may
31+
include source files, build scripts and documentation.
32+
33+
"Reserved Font Name" refers to any names specified as such after the
34+
copyright statement(s).
35+
36+
"Original Version" refers to the collection of Font Software components as
37+
distributed by the Copyright Holder(s).
38+
39+
"Modified Version" refers to any derivative made by adding to, deleting,
40+
or substituting -- in part or in whole -- any of the components of the
41+
Original Version, by changing formats or by porting the Font Software to a
42+
new environment.
43+
44+
"Author" refers to any designer, engineer, programmer, technical
45+
writer or other person who contributed to the Font Software.
46+
47+
PERMISSION & CONDITIONS
48+
Permission is hereby granted, free of charge, to any person obtaining
49+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
50+
redistribute, and sell modified and unmodified copies of the Font
51+
Software, subject to the following conditions:
52+
53+
1) Neither the Font Software nor any of its individual components,
54+
in Original or Modified Versions, may be sold by itself.
55+
56+
2) Original or Modified Versions of the Font Software may be bundled,
57+
redistributed and/or sold with any software, provided that each copy
58+
contains the above copyright notice and this license. These can be
59+
included either as stand-alone text files, human-readable headers or
60+
in the appropriate machine-readable metadata fields within text or
61+
binary files as long as those fields can be easily viewed by the user.
62+
63+
3) No Modified Version of the Font Software may use the Reserved Font
64+
Name(s) unless explicit written permission is granted by the corresponding
65+
Copyright Holder. This restriction only applies to the primary font name as
66+
presented to the users.
67+
68+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69+
Software shall not be used to promote, endorse or advertise any
70+
Modified Version, except to acknowledge the contribution(s) of the
71+
Copyright Holder(s) and the Author(s) or with their explicit written
72+
permission.
73+
74+
5) The Font Software, modified or unmodified, in part or in whole,
75+
must be distributed entirely under this license, and must not be
76+
distributed under any other license. The requirement for fonts to
77+
remain under this license does not apply to any document created
78+
using the Font Software.
79+
80+
TERMINATION
81+
This license becomes null and void if any of the above conditions are
82+
not met.
83+
84+
DISCLAIMER
85+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93+
OTHER DEALINGS IN THE FONT SOFTWARE.
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
Copyright 2014-2025 Adobe (http://www.adobe.com/), with Reserved Font
2+
Name 'Source'. Source is a trademark of Adobe in the United States
3+
and/or other countries.
4+
5+
This Font Software is licensed under the SIL Open Font License,
6+
Version 1.1.
7+
8+
This license is copied below, and is also available with a FAQ at:
9+
http://scripts.sil.org/OFL
10+
11+
-----------------------------------------------------------
12+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
13+
-----------------------------------------------------------
14+
15+
PREAMBLE
16+
The goals of the Open Font License (OFL) are to stimulate worldwide
17+
development of collaborative font projects, to support the font
18+
creation efforts of academic and linguistic communities, and to
19+
provide a free and open framework in which fonts may be shared and
20+
improved in partnership with others.
21+
22+
The OFL allows the licensed fonts to be used, studied, modified and
23+
redistributed freely as long as they are not sold by themselves. The
24+
fonts, including any derivative works, can be bundled, embedded,
25+
redistributed and/or sold with any software provided that any reserved
26+
names are not used by derivative works. The fonts and derivatives,
27+
however, cannot be released under any other type of license. The
28+
requirement for fonts to remain under this license does not apply to
29+
any document created using the fonts or their derivatives.
30+
31+
DEFINITIONS
32+
"Font Software" refers to the set of files released by the Copyright
33+
Holder(s) under this license and clearly marked as such. This may
34+
include source files, build scripts and documentation.
35+
36+
"Reserved Font Name" refers to any names specified as such after the
37+
copyright statement(s).
38+
39+
"Original Version" refers to the collection of Font Software
40+
components as distributed by the Copyright Holder(s).
41+
42+
"Modified Version" refers to any derivative made by adding to,
43+
deleting, or substituting -- in part or in whole -- any of the
44+
components of the Original Version, by changing formats or by porting
45+
the Font Software to a new environment.
46+
47+
"Author" refers to any designer, engineer, programmer, technical
48+
writer or other person who contributed to the Font Software.
49+
50+
PERMISSION & CONDITIONS
51+
Permission is hereby granted, free of charge, to any person obtaining
52+
a copy of the Font Software, to use, study, copy, merge, embed,
53+
modify, redistribute, and sell modified and unmodified copies of the
54+
Font Software, subject to the following conditions:
55+
56+
1) Neither the Font Software nor any of its individual components, in
57+
Original or Modified Versions, may be sold by itself.
58+
59+
2) Original or Modified Versions of the Font Software may be bundled,
60+
redistributed and/or sold with any software, provided that each copy
61+
contains the above copyright notice and this license. These can be
62+
included either as stand-alone text files, human-readable headers or
63+
in the appropriate machine-readable metadata fields within text or
64+
binary files as long as those fields can be easily viewed by the user.
65+
66+
3) No Modified Version of the Font Software may use the Reserved Font
67+
Name(s) unless explicit written permission is granted by the
68+
corresponding Copyright Holder. This restriction only applies to the
69+
primary font name as presented to the users.
70+
71+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
72+
Software shall not be used to promote, endorse or advertise any
73+
Modified Version, except to acknowledge the contribution(s) of the
74+
Copyright Holder(s) and the Author(s) or with their explicit written
75+
permission.
76+
77+
5) The Font Software, modified or unmodified, in part or in whole,
78+
must be distributed entirely under this license, and must not be
79+
distributed under any other license. The requirement for fonts to
80+
remain under this license does not apply to any document created using
81+
the Font Software.
82+
83+
TERMINATION
84+
This license becomes null and void if any of the above conditions are
85+
not met.
86+
87+
DISCLAIMER
88+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
89+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
90+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
91+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
92+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
93+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
94+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
95+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
96+
OTHER DEALINGS IN THE FONT SOFTWARE.
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
Copyright 2017-2022 Adobe (http://www.adobe.com/), with Reserved Font
2+
Name 'Source'. Source is a trademark of Adobe in the United States
3+
and/or other countries.
4+
5+
This Font Software is licensed under the SIL Open Font License,
6+
Version 1.1.
7+
8+
This license is copied below, and is also available with a FAQ at:
9+
http://scripts.sil.org/OFL
10+
11+
-----------------------------------------------------------
12+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
13+
-----------------------------------------------------------
14+
15+
PREAMBLE
16+
The goals of the Open Font License (OFL) are to stimulate worldwide
17+
development of collaborative font projects, to support the font
18+
creation efforts of academic and linguistic communities, and to
19+
provide a free and open framework in which fonts may be shared and
20+
improved in partnership with others.
21+
22+
The OFL allows the licensed fonts to be used, studied, modified and
23+
redistributed freely as long as they are not sold by themselves. The
24+
fonts, including any derivative works, can be bundled, embedded,
25+
redistributed and/or sold with any software provided that any reserved
26+
names are not used by derivative works. The fonts and derivatives,
27+
however, cannot be released under any other type of license. The
28+
requirement for fonts to remain under this license does not apply to
29+
any document created using the fonts or their derivatives.
30+
31+
DEFINITIONS
32+
"Font Software" refers to the set of files released by the Copyright
33+
Holder(s) under this license and clearly marked as such. This may
34+
include source files, build scripts and documentation.
35+
36+
"Reserved Font Name" refers to any names specified as such after the
37+
copyright statement(s).
38+
39+
"Original Version" refers to the collection of Font Software
40+
components as distributed by the Copyright Holder(s).
41+
42+
"Modified Version" refers to any derivative made by adding to,
43+
deleting, or substituting -- in part or in whole -- any of the
44+
components of the Original Version, by changing formats or by porting
45+
the Font Software to a new environment.
46+
47+
"Author" refers to any designer, engineer, programmer, technical
48+
writer or other person who contributed to the Font Software.
49+
50+
PERMISSION & CONDITIONS
51+
Permission is hereby granted, free of charge, to any person obtaining
52+
a copy of the Font Software, to use, study, copy, merge, embed,
53+
modify, redistribute, and sell modified and unmodified copies of the
54+
Font Software, subject to the following conditions:
55+
56+
1) Neither the Font Software nor any of its individual components, in
57+
Original or Modified Versions, may be sold by itself.
58+
59+
2) Original or Modified Versions of the Font Software may be bundled,
60+
redistributed and/or sold with any software, provided that each copy
61+
contains the above copyright notice and this license. These can be
62+
included either as stand-alone text files, human-readable headers or
63+
in the appropriate machine-readable metadata fields within text or
64+
binary files as long as those fields can be easily viewed by the user.
65+
66+
3) No Modified Version of the Font Software may use the Reserved Font
67+
Name(s) unless explicit written permission is granted by the
68+
corresponding Copyright Holder. This restriction only applies to the
69+
primary font name as presented to the users.
70+
71+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
72+
Software shall not be used to promote, endorse or advertise any
73+
Modified Version, except to acknowledge the contribution(s) of the
74+
Copyright Holder(s) and the Author(s) or with their explicit written
75+
permission.
76+
77+
5) The Font Software, modified or unmodified, in part or in whole,
78+
must be distributed entirely under this license, and must not be
79+
distributed under any other license. The requirement for fonts to
80+
remain under this license does not apply to any document created using
81+
the Font Software.
82+
83+
TERMINATION
84+
This license becomes null and void if any of the above conditions are
85+
not met.
86+
87+
DISCLAIMER
88+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
89+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
90+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
91+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
92+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
93+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
94+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
95+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
96+
OTHER DEALINGS IN THE FONT SOFTWARE.
4.63 MB
Binary file not shown.
6.74 MB
Binary file not shown.

‎src/components/Layout.test.tsx‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import userEvent from '@testing-library/user-event';
44
import { MemoryRouter, useLocation } from 'react-router-dom';
55
import { Layout } from './Layout';
66
import { siteConfig } from '@config/site.config';
7+
import { RESUME_TYPOGRAPHY_KEY } from '@/hooks/useResumeTypography';
78

89
// 懒加载子组件用简单 stub 替代,避免测试中等待 dynamic import 与动画。
910
// 注意:Layout 以命名导出方式解构(import('./X').then(m => m.X)),mock 需提供同名导出。
@@ -96,6 +97,34 @@ describe('Layout', () => {
9697
expect(screen.getAllByRole('button', { name: /外观与氛围/ }).length).toBeGreaterThanOrEqual(1);
9798
});
9899

100+
it('桌面与移动端排版开关同步,关闭后恢复原样式', async () => {
101+
const user = userEvent.setup();
102+
renderLayout();
103+
const toggles = screen.getAllByRole('button', { name: 'Resume 排版' });
104+
expect(toggles).toHaveLength(2);
105+
expect(document.querySelector('.site-shell')).not.toHaveAttribute('data-typography');
106+
await user.click(toggles[0]);
107+
expect(document.querySelector('.site-shell')).toHaveAttribute('data-typography', 'resume');
108+
toggles.forEach((toggle) => expect(toggle).toHaveAttribute('aria-pressed', 'true'));
109+
expect(window.localStorage.getItem(RESUME_TYPOGRAPHY_KEY)).toBe('true');
110+
await user.click(toggles[1]);
111+
expect(document.querySelector('.site-shell')).not.toHaveAttribute('data-typography');
112+
toggles.forEach((toggle) => expect(toggle).toHaveAttribute('aria-pressed', 'false'));
113+
expect(window.localStorage.getItem(RESUME_TYPOGRAPHY_KEY)).toBe('false');
114+
});
115+
116+
it('恢复排版选择,导航到其他页面仍保持新排版', async () => {
117+
const user = userEvent.setup();
118+
window.localStorage.setItem(RESUME_TYPOGRAPHY_KEY, 'true');
119+
renderLayout();
120+
await waitFor(() => expect(document.querySelector('.site-shell')).toHaveAttribute('data-typography', 'resume'));
121+
await user.click(screen.getByRole('link', { name: '文章' }));
122+
expect(document.querySelector('.site-shell')).toHaveAttribute('data-typography', 'resume');
123+
await user.click(screen.getAllByRole('button', { name: '打开搜索页' })[0]);
124+
await waitFor(() => expect(probePathname).toBe('/search'));
125+
expect(document.querySelector('.site-shell')).toHaveAttribute('data-typography', 'resume');
126+
});
127+
99128
it('渲染待补完文章入口按钮', () => {
100129
renderLayout();
101130
expect(screen.getAllByRole('link', { name: /查看待补完文章页/ }).length).toBeGreaterThanOrEqual(1);

0 commit comments

Comments
 (0)