Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
22 changes: 9 additions & 13 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,25 @@ on:
push:
branches:
- master # default branch
- chore/upgrade-hexo8-next8 # temporary: remove before merging

jobs:
pages:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js 17.x
uses: actions/setup-node@v2
- uses: actions/checkout@v4
- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: '17'
- name: Cache NPM dependencies
uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.OS }}-npm-cache
restore-keys: |
${{ runner.OS }}-npm-cache
node-version: '20'
cache: 'npm'
- name: Install Dependencies
run: npm install
- name: Build
run: npm run build
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
if: github.ref == 'refs/heads/master'
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
publish_dir: ./public
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ db.json
*.log
node_modules/
public/
.deploy*/
.deploy*/
.claude/*
97 changes: 97 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# CLAUDE.md

此檔案提供給 Claude Code 在本倉庫工作時的快速指引。

## 專案簡介

- **類型**:Hexo 6.1.0 靜態網誌
- **主題**:NexT(位於 `themes/next/`,直接放在 repo 內,未使用 git submodule)
- **站點標題**:代碼玩家 Nick's Blog
- **作者 / 語系**:Nick Chen / `zh-tw`
- **發佈網址**:<https://nick45chen.github.io/Blog/>(root: `/Blog/`,project page 模式)
- **內容主題**:Android Material Design、Hexo 設定等技術筆記

## 常用指令

對應 `package.json` 中的 scripts:

```bash
npm install # 安裝相依套件
npm run server # 本機預覽(hexo server,預設 http://localhost:4000/Blog/)
npm run clean # 清除 public/ 與 db.json
npm run build # 產生靜態檔到 public/
npm run deploy # hexo deploy(_config.yml 的 deploy.type 目前為空,實際部署交給 GitHub Actions)
```

升級 Hexo CLI / 依賴(詳見 `README.md`):

```bash
npm i hexo-cli -g
npm install -g npm-upgrade
npm-upgrade
npm update
```

## 目錄結構

```
.
├── _config.yml # 站點設定(title / url / theme / permalink 等)
├── package.json
├── scaffolds/ # 新文章/草稿/頁面範本(post.md, draft.md, page.md)
├── source/
│ └── _posts/ # Markdown 文章,檔名格式:YYYY-MM-DD-title.md
├── themes/
│ └── next/ # NexT 主題(主題設定檔:themes/next/_config.yml)
└── .github/workflows/pages.yml # GitHub Actions 自動部署
```

## 新增文章流程

```bash
npx hexo new "文章標題"
```

- 會依 `scaffolds/post.md` 在 `source/_posts/` 產生檔案
- 檔名格式 `YYYY-MM-DD-title.md`(由 `_config.yml` 的 `new_post_name` 控制)
- 永久連結格式:`:year/:month/:day/:title/`
- `post_asset_folder: true` → 每篇文章會建立同名資料夾存放圖片

Front matter 範本:

```yaml
---
title: 文章標題
date: YYYY-MM-DD HH:mm:ss
tags:
---
```

寫完後在本機跑 `npm run server` 預覽,確認無誤再 push 到 `master`。

## 部署管線

**目前生效**:`.github/workflows/pages.yml`

- **觸發條件**:push 到 `master`
- **流程**:`actions/checkout` → Node.js 17 → `npm install` → `npm run build` → `peaceiris/actions-gh-pages@v3` 把 `public/` 推到 `gh-pages` 分支
- 使用 `secrets.GITHUB_TOKEN`,不需額外設定 PAT
- GitHub Pages 的 Source 分支需設為 `gh-pages`

**已停用**:`.travis.yml` 仍保留在 repo 中(早期透過 Travis CI 部署),但實際部署改由 GitHub Actions 處理。除非要切回 Travis,否則不必動它。

## 重要設定備忘

- `_config.yml` 的 `url` 與 `root` 是 project page(子目錄)模式:
- `url: https://nick45chen.github.io/Blog/`
- `root: /Blog/`
- 若改名或換 repo,要**同步更新這兩個欄位**,否則靜態資源連結會壞掉
- `theme: next` → 主題本身的設定在 `themes/next/_config.yml`
- `.gitignore` 已排除 `public/`、`node_modules/`、`db.json`、`.deploy*/`,不要把它們加進版控

## Claude 協作守則

- 預設用**繁體中文**回覆(與 commit message / 文章慣例一致)
- 除非使用者明示,**不要自動 commit**,只修改檔案
- 改動 `_config.yml` 或 `themes/next/_config.yml` 後,提醒使用者用 `npm run server` 在本機預覽再 push
- 修改文章 / 設定時,避免一併動到 `themes/next/` 內的主題原始碼,除非使用者明確要求客製主題
Loading
Loading