Skip to content

Commit be87757

Browse files
committed
Require Jekyll for local docs preview
1 parent d3edde8 commit be87757

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

Gemfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
source 'https://rubygems.org'
2+
3+
gem 'github-pages', group: :jekyll_plugins

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
- CI 文档:`docs/ci-workflows.md`
1616
- 英文 CI 文档:`docs/ci-workflows.en.md`
1717
- 中文导航:`docs/navigation.md`
18-
- 英文导航:`docs/navigation.en.md`
18+
- 英文导航:`docs/navigation.en.md`
1919
- 中文博客索引:`docs/blog/index.md`
2020
- 英文博客索引:`docs/blog/index.en.md`
2121

@@ -26,6 +26,8 @@
2626

2727
本地预览建议:
2828

29+
- 本地预览基于 Jekyll,与 GitHub Pages 保持一致。
30+
- 首次使用前,请先安装 Ruby 与 Bundler,并在仓库根目录执行 `bundle install`
2931
- 可运行 `preview/preview-pages.ps1` 在本地生成并预览 Pages HTML。
3032
- 默认地址为 `http://127.0.0.1:4000/`
3133
- 如只想生成 `_site` 而不启动预览,可使用 `preview/preview-pages.ps1 -NoServe`

preview/preview-pages.ps1

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,22 @@ if (Test-Path (Join-Path $repoRoot 'docs\images')) {
5858
Push-Location $repoRoot
5959
try {
6060
$bundle = Get-Command bundle -ErrorAction SilentlyContinue
61-
if ($bundle) {
62-
Write-Host 'Building site with Jekyll (bundle exec jekyll build)...' -ForegroundColor Cyan
63-
& bundle exec jekyll build --source $pagesSrc --destination $siteDir
61+
if (-not $bundle) {
62+
throw "未找到 Bundler。请先安装 Ruby + Bundler,并在仓库根目录执行:bundle install"
6463
}
65-
else {
66-
Write-Warning 'Ruby/Bundler 未安装,改用 GitHub Pages 等效的静态预览方式:直接复制 Markdown 源到 _site。此模式仅用于快速查看文件结构,不会生成最终 HTML。'
67-
Copy-Item (Join-Path $pagesSrc '*') $siteDir -Recurse -Force
64+
65+
Write-Host 'Checking Jekyll/GitHub Pages dependencies...' -ForegroundColor Cyan
66+
& bundle exec jekyll --version | Out-Host
67+
68+
if ($LASTEXITCODE -ne 0) {
69+
throw "Jekyll 不可用。请先在仓库根目录执行:bundle install"
70+
}
71+
72+
Write-Host 'Building site with Jekyll (bundle exec jekyll build)...' -ForegroundColor Cyan
73+
& bundle exec jekyll build --source $pagesSrc --destination $siteDir
74+
75+
if ($LASTEXITCODE -ne 0) {
76+
throw "Jekyll 构建失败,请检查 bundle install 输出和站点配置。"
6877
}
6978

7079
if ($NoServe) {

0 commit comments

Comments
 (0)