Skip to content

Commit 6a321a6

Browse files
committed
font, mermaid, and search
1 parent 8c4fb11 commit 6a321a6

42 files changed

Lines changed: 578 additions & 260 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

source/search/index.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
title: 搜索
3+
---
4+
5+
<div class="search-page">
6+
<div class="search-input-container">
7+
<input autocomplete="off" autocapitalize="off" maxlength="80"
8+
placeholder="输入关键词搜索..." spellcheck="false"
9+
type="search" class="search-input" id="search-input">
10+
</div>
11+
<div class="search-result-container" id="search-results">
12+
<div class="search-result-message"></div>
13+
</div>
14+
</div>
15+
16+
<script>
17+
const searchConfig = {
18+
path : "/search.xml",
19+
top_n_per_article: "-1",
20+
unescape : "false",
21+
trigger: "auto",
22+
preload: "false"
23+
}
24+
</script>
25+
<script src="https://cdn.jsdelivr.net/npm/hexo-generator-searchdb@1.4.0/dist/search.js"></script>
26+
<script src="/js/search.js"></script>

themes/theme/layout/layout.ejs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,8 @@
1717
<%- partial('partials/footer') %>
1818

1919
</div>
20-
21-
<% if (theme.local_search.enable) {%>
22-
<%- partial('partials/search') %>
23-
<% } %>
2420

21+
<script src="<%- url_for('/js/mermaid-zoom.js') %>"></script>
2522

2623
</body>
2724
</html>

themes/theme/layout/partials/head.ejs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,18 @@
3030
<link rel="icon" href="<%- url_for(theme.favicon) %>">
3131
<% } %>
3232

33-
<%# css list %>
34-
<% if (theme.stylesheets !==undefined && theme.stylesheets.length>
35-
0) { %>
36-
<!-- stylesheets list from _config.yml -->
37-
<% theme.stylesheets.forEach(url=> { %>
38-
<link rel="stylesheet" href="<%- url_for(url) %>">
39-
<% }); %>
40-
<% } %>
33+
<%# css list %>
34+
<% if (theme.stylesheets !==undefined && theme.stylesheets.length>
35+
0) { %>
36+
<!-- stylesheets list from _config.yml -->
37+
<% theme.stylesheets.forEach(url=> { %>
38+
<link rel="stylesheet" href="<%- url_for(url) %>">
39+
<% }); %>
40+
<% } %>
41+
42+
<%# font preload - critical slices %>
43+
<link rel="preload" href="<%- url_for('/fonts/latin-base.woff2') %>" as="font" type="font/woff2" crossorigin>
44+
<link rel="preload" href="<%- url_for('/fonts/cjk-common.woff2') %>" as="font" type="font/woff2" crossorigin>
4145

4246
<%# javascript list %>
4347
<% if (theme.scripts !==undefined &&

themes/theme/layout/partials/header.ejs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
<% }%>
3232
<% }); %>
3333
<% if (theme.local_search.enable) {%>
34-
<li class="menu-item search-btn">
35-
<a href="#">搜索</a>
34+
<li class="menu-item">
35+
<a href="/search">搜索</a>
3636
</li>
3737
<% } %>
3838
</ul>

themes/theme/layout/partials/search.ejs

Lines changed: 0 additions & 30 deletions
This file was deleted.

themes/theme/layout/search.ejs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!DOCTYPE html>
2+
<html lang="<%=config.language%>">
3+
<head>
4+
<%- partial('partials/head') %>
5+
</head>
6+
<body>
7+
<div class="wrapper">
8+
<%- partial('partials/header') %>
9+
10+
<div class="main">
11+
<div class="flex-container">
12+
<%- body %>
13+
</div>
14+
</div>
15+
16+
<%- partial('partials/footer') %>
17+
</div>
18+
19+
<script src="<%- url_for('/js/mermaid-zoom.js') %>"></script>
20+
</body>
21+
</html>

themes/theme/source/css/component/button.styl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
white-space nowrap
66
border-radius $margin-m-2
77
font-size $font-size-header
8-
font-weight $font-weight-medium
8+
font-weight 400
99
transition all $transition-duration ease
1010
cursor pointer
1111
border none
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// FONT SLICES - GoogleSansCode 分段字体定义
2+
// 自动生成,包含 5 个 Unicode 范围切片
3+
4+
// Latin 基础字符集(ASCII + 基本拉丁 + 常用标点)
5+
@font-face
6+
font-family 'GoogleSansCode'
7+
font-style normal
8+
font-weight 400
9+
font-display swap
10+
src url('/fonts/latin-base.woff2') format('woff2')
11+
unicode-range U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F
12+
13+
// Latin 扩展(拉丁扩展 A/B + 货币符号 + 特殊字符)
14+
@font-face
15+
font-family 'GoogleSansCode'
16+
font-style normal
17+
font-weight 400
18+
font-display swap
19+
src url('/fonts/latin-ext.woff2') format('woff2')
20+
unicode-range U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF
21+
22+
// CJK 常用汉字(约 3500 字,覆盖 99% 中文内容)
23+
@font-face
24+
font-family 'GoogleSansCode'
25+
font-style normal
26+
font-weight 400
27+
font-display swap
28+
src url('/fonts/cjk-common.woff2') format('woff2')
29+
unicode-range U+4E00-62FF
30+
31+
// CJK 扩展汉字(次常用汉字 + 扩展 A)
32+
@font-face
33+
font-family 'GoogleSansCode'
34+
font-style normal
35+
font-weight 400
36+
font-display swap
37+
src url('/fonts/cjk-ext.woff2') format('woff2')
38+
unicode-range U+6300-9FFF, U+3400-4DBF
39+
40+
// 符号(CJK 标点 + 全角字符)
41+
@font-face
42+
font-family 'GoogleSansCode'
43+
font-style normal
44+
font-weight 400
45+
font-display swap
46+
src url('/fonts/symbols.woff2') format('woff2')
47+
unicode-range U+3000-303F, U+FF00-FFEF

themes/theme/source/css/font.styl

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,119 +1,105 @@
11
text-style(n)
22
font-family $font-family
3-
3+
font-weight 400
4+
45
if n == 'body-default'
56
font-size $font-size-body
6-
font-weight $font-weight-regular
77
line-height $line-height-body
88
color $color-text-primary
99

1010
else if n == 'body-bold'
1111
font-size $font-size-body
12-
font-weight $font-weight-bold
1312
line-height $line-height-body
1413
color $color-text-primary
1514

1615
else if n == 'body-italic'
1716
font-size $font-size-body
18-
font-weight $font-weight-regular
1917
font-style italic
2018
line-height $line-height-body
2119
color $color-text-primary
22-
20+
2321
else if n == 'body-delete'
2422
font-size $font-size-body
25-
font-weight $font-weight-regular
2623
line-height $line-height-body
2724
text-decoration line-through
2825
color $color-text-primary
2926

3027
else if n == 'code-default'
31-
font-family monospace
28+
font-family $font-family
3229
font-size $font-size-code
3330
line-height $line-height-code
3431
color $color-code-default
3532

3633
else if n == 'code-highlight'
37-
font-family monospace
34+
font-family $font-family
3835
font-size $font-size-code
3936
line-height $line-height-code
4037
color $color-code-highlight
4138

4239
else if n == 'code-marker'
43-
font-family monospace
40+
font-family $font-family
4441
font-size $font-size-code
4542
line-height $line-height-code
4643
color $color-code-marker
4744

4845
else if n == 'heading-h1'
4946
font-size $font-size-heading-h1
50-
font-weight $font-weight-bold
5147
line-height $line-height-heading-h1
5248
color $color-text-primary
5349

5450
else if n == 'heading-h2'
5551
font-size $font-size-heading-h2
56-
font-weight $font-weight-bold
5752
line-height $line-height-heading-h2
5853
color $color-text-primary
5954

6055
else if n == 'heading-h3'
6156
font-size $font-size-heading-h3
62-
font-weight $font-weight-bold
6357
line-height $line-height-heading-h3
6458
color $color-text-primary
6559

6660
else if n == 'heading-h4'
6761
font-size $font-size-heading-h4
68-
font-weight $font-weight-bold
6962
line-height $line-height-heading-h4
7063
color $color-text-primary
7164

7265
else if n == 'heading-h5'
7366
font-size $font-size-heading-h5
74-
font-weight $font-weight-semibold
7567
line-height $line-height-heading-h5
7668
color $color-text-primary
7769

7870
else if n == 'heading-h6'
7971
font-size $font-size-heading-h6
80-
font-weight $font-weight-medium
8172
line-height $line-height-heading-h6
8273
color $color-text-primary
8374

8475
else if n == 'footer'
8576
font-size $font-size-footer
86-
font-weight $font-weight-regular
8777
line-height $line-height-footer
8878
color $color-text-secondary
8979

9080
else if n == 'header'
9181
font-size $font-size-header
92-
font-weight $font-weight-medium
9382
line-height $line-height-header
9483
color $color-text-primary
9584

9685
else if n == 'post-date'
9786
font-size $font-size-post-date
98-
font-weight $font-weight-regular
9987
line-height $line-height-post-date
10088
color $color-text-secondary
10189

10290
else if n == 'year-title'
10391
font-size $font-size-year-title
104-
font-weight $font-weight-bold
10592
line-height $line-height-year-title
10693
color $color-text-third
10794

10895
else if n == 'post-tag'
10996
font-size $font-size-post-tag
110-
font-weight $font-weight-medium
11197
line-height $line-height-post-tag
11298
color $color-text-secondary
11399

114100
else if n == 'search-result-message'
115-
font-family monospace
101+
font-family $font-family
116102
font-size $font-size-code
117103
line-height $line-height-code
118104
color $color-text-third
119-
text-transform lowercase
105+
text-transform lowercase

themes/theme/source/css/highlight/ascetic.styl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Original style from softwaremaniacs.org (c) Ivan Sagalaev <Maniac@SoftwareManiac
3131
.name,
3232
.type,
3333
.strong
34-
font-weight: bold
34+
font-weight: normal
3535

3636
.emphasis
3737
font-style: italic

0 commit comments

Comments
 (0)