Skip to content

Commit 9e8bf75

Browse files
committed
首页优化,字体精简
1 parent a4daf27 commit 9e8bf75

13 files changed

Lines changed: 893 additions & 52 deletions

File tree

.github/workflows/DEPLOY.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# EdgeOne Pages 部署说明
2+
3+
## EdgeOne CLI 安装
4+
5+
EdgeOne CLI 已添加到 `devDependencies` 中,运行 `bun install` 时会自动安装。
6+
7+
如果需要在本地使用,也可以全局安装:
8+
9+
```bash
10+
npm install -g edgeone
11+
#
12+
bun add -g edgeone
13+
```
14+
15+
## GitHub Secrets 配置
16+
17+
在 GitHub 仓库设置中添加以下 Secrets:
18+
19+
1. **EDGEONE_API_TOKEN**
20+
- EdgeOne API Token
21+
- 获取方式:EdgeOne 控制台 → API 密钥
22+
23+
2. **EDGEONE_PROJECT_NAME**
24+
- EdgeOne Pages 项目名称
25+
- 在 EdgeOne 控制台创建 Pages 项目时设置
26+
27+
## 部署命令说明
28+
29+
```bash
30+
edgeone pages deploy <outputDirectory> -n <projectName> -t <token> [-e <env>]
31+
```
32+
33+
参数说明:
34+
- `dist`: 构建输出目录(Astro 默认输出目录)
35+
- `-n`: 项目名称(从 GitHub Secrets 获取)
36+
- `-t`: API Token(从 GitHub Secrets 获取)
37+
- `-e`: 环境(可选,如 production/staging)
38+
39+
## 工作流程
40+
41+
1. **推送代码** → 触发 GitHub Actions
42+
2. **安装依赖** → 包括 edgeone CLI
43+
3. **构建项目** → 生成 dist 目录
44+
4. **字体子集化** → 自动运行(通过 Astro 集成)
45+
5. **部署** → 使用 edgeone CLI 部署到 EdgeOne Pages
46+
47+
## 本地测试部署
48+
49+
如果需要本地测试部署:
50+
51+
```bash
52+
# 确保已安装依赖
53+
bun install
54+
55+
# 构建项目
56+
bun run build
57+
58+
# 部署(需要设置环境变量或直接传参)
59+
bunx edgeone pages deploy dist -n <项目名称> -t <API_TOKEN>
60+
```
61+
62+
## 注意事项
63+
64+
1. EdgeOne CLI 已添加到 `devDependencies`,不需要全局安装
65+
2. 在 GitHub Actions 中使用 `bunx edgeone` 会自动使用项目中的版本
66+
3. 确保 GitHub Secrets 已正确配置
67+
4. 部署前会验证构建输出和字体文件

.github/workflows/deploy.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Build and Deploy to EdgeOne
2+
3+
# 向主干分支推送代码时触发部署
4+
on:
5+
push:
6+
branches:
7+
- astro-pure-v4_0_3
8+
workflow_dispatch: # 允许手动触发
9+
10+
jobs:
11+
build-and-deploy:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
18+
- name: Setup Bun
19+
uses: oven-sh/setup-bun@v1
20+
with:
21+
bun-version: latest
22+
23+
- name: Setup Python (for font subsetting)
24+
uses: actions/setup-python@v4
25+
with:
26+
python-version: '3.x'
27+
28+
- name: Install fonttools
29+
run: pip install fonttools brotli
30+
31+
- name: Install dependencies
32+
run: bun install
33+
# edgeone CLI 已包含在 devDependencies 中
34+
35+
- name: Build project
36+
run: bun run build
37+
38+
- name: Generate font subset (post-build script)
39+
run: node scripts/subset-fonts.js
40+
continue-on-error: true # 如果字体子集化失败,不影响部署
41+
42+
- name: Verify build output
43+
run: |
44+
echo "📦 Build output directory contents:"
45+
ls -lh dist/ | head -20
46+
echo ""
47+
echo "🔤 Font files:"
48+
ls -lh public/fonts/ 2>/dev/null || echo "No font files found"
49+
50+
- name: Deploy to EdgeOne Pages
51+
run: bunx edgeone pages deploy dist -n ${{ secrets.EDGEONE_PROJECT_NAME }} -t ${{ secrets.EDGEONE_API_TOKEN }}
52+
env:
53+
EDGEONE_API_TOKEN: ${{ secrets.EDGEONE_API_TOKEN }}
54+
EDGEONE_PROJECT_NAME: ${{ secrets.EDGEONE_PROJECT_NAME }}

.gitignore

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,12 @@ src/data/comments.json
9191
b.html
9292
localhost*
9393
public/fonts/crjk*
94-
bun.lockb
94+
bun.lockb
95+
96+
# Lighthouse reports
97+
lighthouse-reports/
98+
99+
# Font source files (large files, should be downloaded separately)
100+
fonts-source/*.ttf
101+
fonts-source/*.otf
102+
!fonts-source/.gitkeep

bun.lock

Lines changed: 318 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fonts-source/.gitkeep

Whitespace-only changes.

package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@
1515
"format": "prettier --write '**/*.{js,jsx,ts,tsx,md,mdx,astro}'",
1616
"lint": "eslint --fix 'src/**/*.{js,ts,jsx,tsx,astro}'",
1717
"yijiansilian": "bun lint && bun sync && bun check && bun format",
18-
"clean": "rm -rf .astro .vercel dist"
18+
"clean": "rm -rf .astro .vercel dist",
19+
"lighthouse": "node scripts/lighthouse.js",
20+
"pagespeed": "node scripts/lighthouse.js",
21+
"subset-fonts": "node scripts/subset-fonts.js",
22+
"build:fonts": "bun run build && bun run subset-fonts"
1923
},
2024
"dependencies": {
2125
"@astrojs/check": "^0.9.4",
@@ -51,6 +55,9 @@
5155
"@iconify-json/mingcute": "^1.2.5",
5256
"eslint": "^9.31.0",
5357
"eslint-plugin-astro": "^1.3.1",
58+
"lighthouse": "^12.0.0",
59+
"chrome-launcher": "^1.1.0",
60+
"edgeone": "^1.1.20",
5461
"prettier": "^3.6.2",
5562
"prettier-plugin-astro": "^0.14.1",
5663
"rollup-plugin-visualizer": "^6.0.3",

packages/pure/components/basic/Footer.astro

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ const socialLinks = normalizeSocialLinks(footerConf.social)
101101
<a
102102
href='https://github.com/cworld1/astro-theme-pure'
103103
target='_blank'
104-
class='hover:text-primary external-link italic'
104+
class='hover:text-primary'
105105
>
106-
<DevIcon name='devicon:astro' class='size-4' />
106+
{/* <DevIcon name='devicon:astro' class='size-4' /> */}
107107
Astro & Pure theme
108108
</a>
109109
<span class='inline-flex items-center gap-x-1'>powered</span>
@@ -124,7 +124,7 @@ const socialLinks = normalizeSocialLinks(footerConf.social)
124124

125125
return (
126126
<a
127-
class='inline-block external-link text-muted-foreground transition-all hover:text-muted-foreground/75'
127+
class='inline-block text-muted-foreground transition-all hover:text-muted-foreground/75'
128128
href={url}
129129
aria-label={label}
130130
target='_blank'

public/styles/fonts.css

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/* 思源宋体 - 使用本地子集字体文件 */
2+
3+
@font-face {
4+
font-family: 'Noto Serif CJK';
5+
src: url('/fonts/NotoSerifCJK-Subset.woff2') format('woff2');
6+
font-display: swap;
7+
font-weight: normal;
8+
font-style: normal;
9+
}
10+
11+
body {
12+
/* 使用本地字体,fallback 到系统字体 */
13+
font-family: "Noto Serif CJK", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
14+
font-weight: normal;
15+
text-autospace: normal;
16+
}
17+
18+
@font-face {
19+
font-family: 'ZSFT-e';
20+
src: url('/fonts/LinBiolinum.woff2') format('woff2');
21+
font-display: swap;
22+
}

public/styles/global.css

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
/* External font loading - Loaded asynchronously via JavaScript to avoid blocking render */
2-
/* Font CSS will be loaded dynamically in BaseHead.astro */
1+
/* 字体定义已移至 /styles/fonts.css */
2+
/* 这里只保留 body 样式,字体通过 fonts.css 加载 */
33

44
body {
5-
/* JyunsaiKaai - Fallback fonts ensure text is visible even if external font hasn't loaded */
65
font-family: "Noto Serif CJK", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
76
font-weight: normal;
87
text-autospace: normal;

0 commit comments

Comments
 (0)