Skip to content

Commit 27357a0

Browse files
committed
style: 统一代码风格,使用单引号并格式化代码
refactor: 优化组件结构和样式类名顺序 chore: 添加prettier配置和格式化脚本 style: 调整markdown样式文件格式 docs: 更新README.md表格格式和SEO文档 refactor: 简化axios导出和sitemap生成逻辑
1 parent bf9647a commit 27357a0

22 files changed

Lines changed: 3208 additions & 1420 deletions

blog-web/.prettierrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"plugins": ["prettier-plugin-tailwindcss"],
3+
"tailwindStylesheet": "src/styles/global.css",
4+
"semi": true,
5+
"singleQuote": true,
6+
"tabWidth": 2,
7+
"trailingComma": "es5",
8+
"printWidth": 80
9+
}

blog-web/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ To learn more about the folder structure of an Astro project, refer to [our guid
3434

3535
All commands are run from the root of the project, from a terminal:
3636

37-
| Command | Action |
38-
| :------------------------ | :----------------------------------------------- |
39-
| `pnpm install` | Installs dependencies |
37+
| Command | Action |
38+
| :--------------------- | :----------------------------------------------- |
39+
| `pnpm install` | Installs dependencies |
4040
| `pnpm dev` | Starts local dev server at `localhost:4321` |
4141
| `pnpm build` | Build your production site to `./dist/` |
4242
| `pnpm preview` | Preview your build locally, before deploying |

blog-web/SEO_README.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
## 🎯 已实现的SEO功能
66

77
### 1. Meta标签优化
8+
89
- ✅ 基础meta标签(title, description, keywords, author)
910
- ✅ Open Graph标签(社交媒体分享优化)
1011
- ✅ Twitter Card标签
@@ -13,18 +14,21 @@
1314
- ✅ Robots meta标签
1415

1516
### 2. 结构化数据(Schema.org)
17+
1618
- ✅ WebSite结构化数据
1719
- ✅ BlogPosting结构化数据
1820
- ✅ Person和Organization数据
1921
- ✅ JSON-LD格式实现
2022

2123
### 3. 站点地图
24+
2225
- ✅ 动态生成sitemap-index.xml
2326
- ✅ 静态页面sitemap
2427
- ✅ 博客文章动态sitemap
2528
- ✅ Robots.txt优化
2629

2730
### 4. 技术优化
31+
2832
- ✅ HTML压缩
2933
- ✅ 内联样式优化
3034
- ✅ 爬虫友好的robots.txt
@@ -64,7 +68,7 @@ src/
6468
import Layout from '../layouts/Layout.astro';
6569
---
6670
67-
<Layout
71+
<Layout
6872
title="页面标题"
6973
description="页面描述"
7074
keywords="关键词1,关键词2"
@@ -84,7 +88,7 @@ import SEO from '../components/SEO.astro';
8488
8589
<html>
8690
<head>
87-
<SEO
91+
<SEO
8892
title="页面标题"
8993
description="页面描述"
9094
keywords="关键词1,关键词2"
@@ -123,20 +127,23 @@ import SEO from '../components/SEO.astro';
123127
## 📊 SEO检查清单
124128

125129
### 页面级别
130+
126131
- [ ] 每个页面都有唯一的title(10-60字符)
127132
- [ ] 每个页面都有描述性的meta description(50-160字符)
128133
- [ ] 关键词相关且不过度堆砌
129134
- [ ] 图片都有alt属性
130135
- [ ] 内部链接结构合理
131136

132137
### 技术级别
138+
133139
- [x] 站点地图正常生成
134140
- [x] Robots.txt配置正确
135141
- [x] 结构化数据验证通过
136142
- [x] Open Graph标签完整
137143
- [x] 页面加载速度优化
138144

139145
### 内容级别
146+
140147
- [ ] 内容原创且有价值
141148
- [ ] 标题层级结构清晰(H1-H6)
142149
- [ ] 内容长度适中
@@ -150,18 +157,18 @@ import SEO from '../components/SEO.astro';
150157

151158
```javascript
152159
export default defineConfig({
153-
site: "https://blog.exquisitecore.xyz", // 站点URL
160+
site: 'https://blog.exquisitecore.xyz', // 站点URL
154161
integrations: [
155162
sitemap({
156163
changefreq: 'weekly',
157164
priority: 0.7,
158-
filter: (page) => !page.includes('/admin')
159-
})
165+
filter: (page) => !page.includes('/admin'),
166+
}),
160167
],
161168
compressHTML: true, // HTML压缩
162169
build: {
163-
inlineStylesheets: 'auto' // 样式优化
164-
}
170+
inlineStylesheets: 'auto', // 样式优化
171+
},
165172
});
166173
```
167174

@@ -197,4 +204,4 @@ PUBLIC_API_URL=http://localhost:8080
197204
- [Schema.org文档](https://schema.org/)
198205
- [Open Graph协议](https://ogp.me/)
199206
- [Twitter Card文档](https://developer.twitter.com/en/docs/twitter-for-websites/cards)
200-
- [Astro SEO指南](https://docs.astro.build/en/guides/integrations-guide/sitemap/)
207+
- [Astro SEO指南](https://docs.astro.build/en/guides/integrations-guide/sitemap/)

blog-web/astro.config.mjs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
// @ts-check
2-
import { defineConfig } from "astro/config";
2+
import { defineConfig } from 'astro/config';
33

4-
import tailwindcss from "@tailwindcss/vite";
4+
import tailwindcss from '@tailwindcss/vite';
55

6-
import solidJs from "@astrojs/solid-js";
6+
import solidJs from '@astrojs/solid-js';
77

8-
import sitemap from "@astrojs/sitemap";
8+
import sitemap from '@astrojs/sitemap';
99

10-
import node from "@astrojs/node";
10+
import node from '@astrojs/node';
1111

1212
// https://astro.build/config
1313
export default defineConfig({
1414
vite: {
1515
plugins: [tailwindcss()],
1616
},
1717

18-
site: "https://blog.exquisitecore.xyz",
18+
site: 'https://blog.exquisitecore.xyz',
1919
integrations: [
2020
solidJs({ devtools: true }),
2121
sitemap({
@@ -28,17 +28,17 @@ export default defineConfig({
2828
// 自定义URL
2929
customPages: [
3030
'https://blog.exquisitecore.xyz/tools',
31-
'https://blog.exquisitecore.xyz/tools/markdownrender'
32-
]
33-
})
31+
'https://blog.exquisitecore.xyz/tools/markdownrender',
32+
],
33+
}),
3434
],
35-
output: "static",
35+
output: 'static',
3636
adapter: node({
37-
mode: "standalone",
37+
mode: 'standalone',
3838
}),
3939
// SEO相关配置
4040
compressHTML: true,
4141
build: {
42-
inlineStylesheets: 'auto'
43-
}
42+
inlineStylesheets: 'auto',
43+
},
4444
});

blog-web/package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
"build:wasm": "wasm-pack build md-wasm --target web",
99
"preview": "astro preview",
1010
"astro": "astro",
11-
"start": "HOST=0.0.0.0 PORT=4321 node ./dist/server/entry.mjs"
11+
"start": "HOST=0.0.0.0 PORT=4321 node ./dist/server/entry.mjs",
12+
"format": "prettier --write .",
13+
"format:check": "prettier --check ."
1214
},
1315
"dependencies": {
1416
"@astrojs/node": "^9.2.2",
@@ -25,6 +27,8 @@
2527
"tailwindcss": "^4.1.7"
2628
},
2729
"devDependencies": {
30+
"prettier": "^3.6.2",
31+
"prettier-plugin-tailwindcss": "^0.6.14",
2832
"solid-devtools": "^0.34.0"
2933
}
3034
}

0 commit comments

Comments
 (0)