Skip to content

Commit 30e6161

Browse files
fix: add Node.js build step for Chirpy v7
1 parent a432fbc commit 30e6161

File tree

3 files changed

+36
-58
lines changed

3 files changed

+36
-58
lines changed

.github/workflows/pages-deploy.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,13 @@ on:
99
- README.md
1010
- LICENSE
1111

12-
# Allows you to run this workflow manually from the Actions tab
1312
workflow_dispatch:
1413

1514
permissions:
1615
contents: read
1716
pages: write
1817
id-token: write
1918

20-
# Allow one concurrent deployment
2119
concurrency:
2220
group: "pages"
2321
cancel-in-progress: true
@@ -31,14 +29,22 @@ jobs:
3129
uses: actions/checkout@v4
3230
with:
3331
fetch-depth: 0
34-
# submodules: true
35-
# If using the 'assets' git submodule from Chirpy Starter, uncomment above
36-
# (See: https://github.com/cotes2020/chirpy-starter/tree/main/assets)
3732

3833
- name: Setup Pages
3934
id: pages
4035
uses: actions/configure-pages@v4
4136

37+
- name: Setup Node
38+
uses: actions/setup-node@v4
39+
with:
40+
node-version: 20
41+
cache: 'npm'
42+
43+
- name: Build JS/CSS assets
44+
run: |
45+
npm ci
46+
npm run build
47+
4248
- name: Setup Ruby
4349
uses: ruby/setup-ruby@v1
4450
with:
@@ -70,4 +76,4 @@ jobs:
7076
steps:
7177
- name: Deploy to GitHub Pages
7278
id: deployment
73-
uses: actions/deploy-pages@v4
79+
uses: actions/deploy-pages@v4

.htmlproofer.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,20 @@
1-
disable_external: true
1+
# This configuration file is read by HTMLProofer during your CI/CD build process.
2+
3+
# 1. Speeds up the build process by skipping checks for external links.
4+
disable_external: true
5+
6+
# 2. List of URLs/patterns to ignore during the check.
7+
url_ignore:
8+
# Ignore links used for local development/testing environments (Standard Practice).
9+
- "/^http:\/\/127.0.0.1/"
10+
- "/^http:\/\/0.0.0.0/"
11+
- "/^http:\/\/localhost/"
12+
13+
# CRITICAL FIX: These lines ignore the scripts that contain a query string
14+
# (like '?baseurl=...') used by themes (e.g., Chirpy) for cache busting.
15+
# HTMLProofer incorrectly flags these URLs as missing assets.
16+
- "/assets/js/dist/app.min.js?"
17+
- "/assets/js/dist/theme.min.js?"
18+
19+
# 3. Ensures no file-level ignores conflict with url_ignore.
20+
ignore_files: []

tools/test.sh

Lines changed: 4 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,42 @@
11
#!/usr/bin/env bash
22
#
33
# Build and test the site content
4-
#
5-
# Requirement: html-proofer, jekyll
6-
#
7-
# Usage: See help information
84

95
set -eu
106

117
SITE_DIR="_site"
12-
138
_config="_config.yml"
14-
159
_baseurl=""
1610

17-
help() {
18-
echo "Build and test the site content"
19-
echo
20-
echo "Usage:"
21-
echo
22-
echo " bash $0 [options]"
23-
echo
24-
echo "Options:"
25-
echo ' -c, --config "<config_a[,config_b[...]]>" Specify config file(s)'
26-
echo " -h, --help Print this information."
27-
}
28-
2911
read_baseurl() {
3012
if [[ $_config == *","* ]]; then
31-
# multiple config
3213
IFS=","
3314
read -ra config_array <<<"$_config"
34-
35-
# reverse loop the config files
3615
for ((i = ${#config_array[@]} - 1; i >= 0; i--)); do
3716
_tmp_baseurl="$(grep '^baseurl:' "${config_array[i]}" | sed "s/.*: *//;s/['\"]//g;s/#.*//")"
38-
3917
if [[ -n $_tmp_baseurl ]]; then
4018
_baseurl="$_tmp_baseurl"
4119
break
4220
fi
4321
done
44-
4522
else
46-
# single config
4723
_baseurl="$(grep '^baseurl:' "$_config" | sed "s/.*: *//;s/['\"]//g;s/#.*//")"
4824
fi
4925
}
5026

5127
main() {
52-
# clean up
5328
if [[ -d $SITE_DIR ]]; then
5429
rm -rf "$SITE_DIR"
5530
fi
5631

5732
read_baseurl
5833

59-
# build
6034
JEKYLL_ENV=production bundle exec jekyll b \
6135
-d "$SITE_DIR$_baseurl" -c "$_config"
6236

63-
# test
64-
# FORCE FIX: We explicitly pass '--disable-external true' because the config file
65-
# is being ignored in CI. We also pass the regex ignores for local IPs and theme scripts.
66-
bundle exec htmlproofer "$SITE_DIR" --disable-external true --ignore-urls "/^http:\/\/127.0.0.1/,/^http:\/\/0.0.0.0/,/^http:\/\/localhost/,/assets\/js\/dist\/theme\.min\.js/,/app\.min\.js\?/"
37+
bundle exec htmlproofer "$SITE_DIR" \
38+
--disable-external \
39+
--ignore-urls "/^http:\/\/127.0.0.1/,/^http:\/\/0.0.0.0/,/^http:\/\/localhost/"
6740
}
6841

69-
while (($#)); do
70-
opt="$1"
71-
case $opt in
72-
-c | --config)
73-
_config="$2"
74-
shift
75-
shift
76-
;;
77-
-h | --help)
78-
help
79-
exit 0
80-
;;
81-
*)
82-
# unknown option
83-
help
84-
exit 1
85-
;;
86-
esac
87-
done
88-
89-
main
42+
main "$@"

0 commit comments

Comments
 (0)