Files
blog/README.md
T

86 lines
3.3 KiB
Markdown
Raw Normal View History

2026-01-25 16:13:14 +08:00
# 博客项目说明
2026-01-20 23:50:10 +08:00
2026-01-25 16:13:14 +08:00
本项目使用 Hugo 构建,主题为 `Ying`。以下是主要的配置说明与脚本使用指南,方便后续查阅和维护。
2026-01-20 23:50:10 +08:00
2026-01-25 16:13:14 +08:00
## 1. 常用脚本与工具 (Scripts)
2026-01-20 23:50:10 +08:00
2026-01-25 16:13:14 +08:00
项目包含多个 PowerShell 和 Node.js 脚本,用于自动化维护、检查和部署。
2026-01-20 23:50:10 +08:00
2026-01-25 16:13:14 +08:00
### 1.1 日常维护
* **新建文章 (`./new_post.ps1`)**
* **用途**: 交互式创建新的博客文章。
* **功能**: 自动引导输入标题、Slug、分类、标签等信息,并按 `YYYY-MM-DD-Slug` 格式创建 Page Bundle 目录和文件。
* **运行**:
```powershell
./new_post.ps1
2026-01-20 23:50:10 +08:00
```
2026-01-25 16:13:14 +08:00
* **手动构建与检查 (`./deploy.ps1`)**
* **用途**: 手动执行构建,包含友链健康检查。
* **流程**:
1. 运行 `scripts/check_links.js` 检查友链连通性。
2. 如果检查通过,执行 `hugo --minify` 生成静态文件。
* **运行**:
```powershell
./deploy.ps1
```
2026-01-20 23:50:10 +08:00
2026-01-25 16:13:14 +08:00
### 1.2 自动化与 CI/CD 工具
2026-01-20 23:50:10 +08:00
2026-01-25 16:13:14 +08:00
以下脚本主要在 GitHub Actions (`.github/workflows/upy.yml`) 中自动运行,也可手动用于调试:
2026-01-20 23:50:10 +08:00
2026-01-25 16:13:14 +08:00
* **友链数据同步 (`scripts/update_link_lite_json.ps1`)**
* **功能**: 将 `themes/Ying/data/links.yaml` (YAML源数据) 转换为 `themes/Ying/static/json/link_lite.json`,供前端 JS 和检查脚本使用。
2026-01-20 23:50:10 +08:00
2026-01-25 16:13:14 +08:00
* **友链健康检查 (`scripts/check_links.js`)**
* **功能**: 读取 `link_lite.json`,并发检查所有友链的可访问性。
* **依赖**: `node-fetch` (内置于 Node 18+ 或作为依赖)。
2026-01-20 23:50:10 +08:00
2026-01-25 16:13:14 +08:00
* **朋友圈数据生成 (`scripts/generate_circle_data.js`)**
* **功能**: 根据友链抓取 RSS/Atom 订阅源,生成朋友圈更新数据 (`friend_circle_data.json`)。
* **依赖**: `rss-parser`.
* **构建安全预处理 (`scripts/add_draft_to_hidden.ps1`)**
* **功能**: 在构建前扫描 `content/post`,将标记为 `status: hidden` 的文章强制设置为 `draft: true`,防止隐私文章意外泄露到公共列表。
* **CDN 刷新 (`scripts/RefreshCDN.py`)**
* **功能**: 部署完成后调用 DogeCloud API 刷新 CDN 缓存。
* **配置**: 需要在环境变量中设置 `DOGECLOUD_ACCESS_KEY` 等参数。
---
## 2. 基础配置 (`hugo.toml`)
位于项目根目录下,控制网站的全局行为。
* **网站信息**: 标题、BaseURL、语言等。
* **固定链接 (Permalinks)**:
```toml
[permalinks]
post = "/:slug"
2026-01-20 23:50:10 +08:00
```
2026-01-25 16:13:14 +08:00
文章页面使用 Front Matter 中的 `slug` 字段作为文件名(例如 `https://usj.cc/my-post.html`)。
2026-01-20 23:50:10 +08:00
2026-01-25 16:13:14 +08:00
## 3. 主题配置
* **主题目录**: `themes/Ying/`
* **友链数据**: `themes/Ying/data/links.yaml`
* 添加友链请直接编辑此 YAML 文件,构建时会自动同步到 JSON。
## 4. 文章管理指南
2026-01-20 23:50:10 +08:00
### URL 设置
文章默认使用 `slug` 字段作为 URL 的文件名。
```yaml
title: "我的文章"
date: 2023-01-01
slug: "my-post"
```
生成的链接为: `https://usj.cc/my-post.html`
2026-01-25 16:13:14 +08:00
### 隐藏文章
如果你想写一篇不公开在列表显示的文章(但可以通过链接访问):
1. 在 Front Matter 中添加 `status: hidden`。
2. 自动化脚本会在构建时将其标记为 `draft: true` (配合特殊构建逻辑) 或进行其他处理。
*注:具体表现取决于 CI 脚本的逻辑,通常用于草稿或隐藏页。*