Skip to content

Commit 5124dec

Browse files
authored
Merge pull request #58 from awesome-doge/fix/book-pages-content
修復書籍頁面:移除失效圖片、改善程式碼區塊樣式
2 parents d4ccd6f + 89ca266 commit 5124dec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+6336
-653
lines changed

.github/workflows/run.yml

Lines changed: 147 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,161 @@
1-
name: Build and deploy Jekyll site to GitHub Pages
1+
name: Build and Deploy Cypherpunks Taiwan V2.0
22

33
on:
44
push:
55
branches:
66
- master
7+
pull_request:
8+
branches:
9+
- master
10+
11+
# Sets permissions of the GITHUB_TOKEN
12+
permissions:
13+
contents: write
14+
pages: write
15+
id-token: write
16+
17+
# Allow only one concurrent deployment
18+
concurrency:
19+
group: "pages"
20+
cancel-in-progress: true
721

822
jobs:
9-
build-and-deploy:
10-
runs-on: ubuntu-22.04
11-
permissions:
12-
contents: write
23+
build:
24+
runs-on: ubuntu-latest
1325
steps:
14-
- uses: actions/checkout@v4
15-
- name: Set up Ruby
26+
- name: Checkout repository
27+
uses: actions/checkout@v4
28+
29+
# Setup Node.js for Tailwind CSS
30+
- name: Setup Node.js
31+
uses: actions/setup-node@v4
32+
with:
33+
node-version: '20'
34+
cache: 'npm'
35+
36+
- name: Install Node dependencies
37+
run: npm ci || npm install
38+
39+
- name: Build Tailwind CSS
40+
run: npm run css:build
41+
42+
# Setup Ruby for Jekyll
43+
- name: Setup Ruby
1644
uses: ruby/setup-ruby@v1
1745
with:
18-
ruby-version: '3.0'
46+
ruby-version: '3.2'
1947
bundler-cache: true
20-
- name: Install dependencies
48+
49+
- name: Install Ruby dependencies
2150
run: |
22-
bundle config unset deployment
23-
sudo gem install bundler:2.2.15
24-
bundle install
25-
bundle add kramdown-parser-gfm
26-
bundle install
27-
- name: Build site
28-
run: bundle exec jekyll build
51+
bundle config set --local path 'vendor/bundle'
52+
bundle install --jobs 4 --retry 3
53+
54+
- name: Build Jekyll site
55+
run: |
56+
# Check if this is a project page (repo name != owner.github.io)
57+
REPO_NAME="${GITHUB_REPOSITORY#*/}"
58+
OWNER="${GITHUB_REPOSITORY_OWNER}"
59+
if [[ "$REPO_NAME" != "${OWNER}.github.io" ]]; then
60+
echo "Building for project page: baseurl=/${REPO_NAME}"
61+
bundle exec jekyll build --baseurl "/${REPO_NAME}"
62+
else
63+
echo "Building for user/org page: no baseurl"
64+
bundle exec jekyll build
65+
fi
66+
env:
67+
JEKYLL_ENV: production
68+
69+
- name: Build Pagefind search index
70+
run: npx pagefind --site _site --output-path _site/pagefind
71+
72+
- name: Upload artifact
73+
uses: actions/upload-pages-artifact@v3
74+
with:
75+
path: ./_site
76+
77+
deploy:
78+
if: github.ref == 'refs/heads/master'
79+
needs: build
80+
runs-on: ubuntu-latest
81+
environment:
82+
name: github-pages
83+
url: ${{ steps.deployment.outputs.page_url }}
84+
steps:
2985
- name: Deploy to GitHub Pages
30-
uses: peaceiris/actions-gh-pages@v3
86+
id: deployment
87+
uses: actions/deploy-pages@v4
88+
89+
# Quality Checks (run on PRs)
90+
quality-check:
91+
if: github.event_name == 'pull_request'
92+
needs: build
93+
runs-on: ubuntu-latest
94+
steps:
95+
- name: Checkout
96+
uses: actions/checkout@v4
97+
98+
- name: Download artifact
99+
uses: actions/download-artifact@v4
100+
with:
101+
name: github-pages
102+
path: _site
103+
104+
- name: Extract artifact
105+
run: |
106+
cd _site
107+
tar -xvf artifact.tar
108+
rm artifact.tar
109+
110+
# Link Checker
111+
- name: Check links
112+
uses: lycheeverse/lychee-action@v1
31113
with:
32-
github_token: ${{ secrets.GITHUB_TOKEN }}
33-
publish_dir: ./_site
114+
args: --verbose --no-progress --accept 999 './_site/**/*.html'
115+
fail: false
116+
117+
# HTML Validation
118+
- name: Setup Node.js for html-validate
119+
uses: actions/setup-node@v4
120+
with:
121+
node-version: '20'
122+
123+
- name: Install html-validate
124+
run: npm install -g html-validate
125+
126+
- name: Validate HTML
127+
run: |
128+
html-validate --config .htmlvalidate.json "_site/**/*.html" || true
129+
continue-on-error: true
130+
131+
# Accessibility Check
132+
- name: Install pa11y
133+
run: npm install -g pa11y-ci
134+
135+
- name: Run accessibility check
136+
run: |
137+
pa11y-ci --config .pa11yci.json || true
138+
continue-on-error: true
139+
140+
# Image Compression (run on PRs with image changes)
141+
compress-images:
142+
if: github.event_name == 'pull_request'
143+
runs-on: ubuntu-latest
144+
steps:
145+
- name: Checkout
146+
uses: actions/checkout@v4
147+
148+
- name: Compress Images
149+
id: compress
150+
uses: calibreapp/image-actions@main
151+
with:
152+
githubToken: ${{ secrets.GITHUB_TOKEN }}
153+
compressOnly: true
154+
ignorePaths: 'node_modules/**,vendor/**,_site/**'
155+
continue-on-error: true
156+
157+
- name: Create image compression summary
158+
if: steps.compress.outputs.markdown != ''
159+
run: |
160+
echo "## Image Compression Results" >> $GITHUB_STEP_SUMMARY
161+
echo "${{ steps.compress.outputs.markdown }}" >> $GITHUB_STEP_SUMMARY

.htmlvalidate.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"extends": ["html-validate:recommended"],
3+
"rules": {
4+
"no-trailing-whitespace": "off",
5+
"void-style": "off",
6+
"prefer-native-element": "off",
7+
"no-inline-style": "off",
8+
"require-sri": "off",
9+
"script-type": "off",
10+
"attribute-allowed-values": "off",
11+
"element-permitted-content": "warn",
12+
"no-unknown-elements": "warn",
13+
"wcag/h30": "warn",
14+
"wcag/h32": "warn",
15+
"wcag/h36": "warn",
16+
"wcag/h37": "warn",
17+
"wcag/h67": "warn"
18+
},
19+
"transform": {
20+
"^.*\\.html$": "html-validate:plain"
21+
}
22+
}

.pa11yci.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"defaults": {
3+
"timeout": 30000,
4+
"wait": 500,
5+
"standard": "WCAG2AA",
6+
"runners": ["axe"],
7+
"chromeLaunchConfig": {
8+
"args": ["--no-sandbox", "--disable-setuid-sandbox"]
9+
}
10+
},
11+
"urls": [
12+
"http://localhost:4000/",
13+
"http://localhost:4000/blog/",
14+
"http://localhost:4000/tags/",
15+
"http://localhost:4000/categories/",
16+
"http://localhost:4000/archive/"
17+
]
18+
}

Gemfile

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,26 @@
11
# frozen_string_literal: true
22

33
source "https://rubygems.org"
4-
gemspec
54

5+
# Jekyll 4.x
6+
gem "jekyll", "~> 4.3"
7+
8+
# Jekyll plugins
69
group :jekyll_plugins do
7-
gem "jekyll-feed", "~> 0.6"
8-
gem "jekyll-sitemap"
9-
gem "jekyll-paginate"
10-
gem "jekyll-seo-tag"
10+
gem "jekyll-feed", "~> 0.17"
11+
gem "jekyll-sitemap", "~> 1.4"
12+
gem "jekyll-paginate", "~> 1.1"
13+
gem "jekyll-seo-tag", "~> 2.8"
14+
gem "kramdown-parser-gfm", "~> 1.1"
15+
end
16+
17+
# Performance
18+
gem "webrick", "~> 1.8" # Required for Ruby 3.0+
19+
20+
# Windows specific
21+
platforms :mingw, :x64_mingw, :mswin, :jruby do
22+
gem "tzinfo", ">= 1", "< 3"
23+
gem "tzinfo-data"
1124
end
1225

26+
gem "wdm", "~> 0.1", :platforms => [:mingw, :x64_mingw, :mswin]

0 commit comments

Comments
 (0)