Skip to content

Commit

Permalink
build(scripts): prepend BASE_URL to assets path in 404.html
Browse files Browse the repository at this point in the history
  • Loading branch information
remarkablemark committed Dec 11, 2022
1 parent f33e130 commit 47640d7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ jobs:

- name: Build docs
run: scripts/docs.sh
env:
BASE_URL: /${{ github.event.repository.name }}/

- name: Deploy
if: github.ref == 'refs/heads/master'
Expand Down
7 changes: 7 additions & 0 deletions scripts/docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,20 @@ README_START='<!-- readme-content-start -->'
README_END='<!-- readme-content-end -->'
README_PLACEHOLDER='<!-- readme-content-placeholder -->'
README_REPLACEMENT='<h1>Not Found</h1>'
ASSETS_URL='assets/'

if [[ $CF_PAGES == '1' ]]; then
BASE_URL='/'
fi

if [[ $(uname) == 'Linux' ]]; then
sed -i "/$README_START/,/$README_END/d" $NOT_FOUND_PATH
sed -i "s|$README_PLACEHOLDER|$README_REPLACEMENT|" $NOT_FOUND_PATH
sed -i "s|$ASSETS_URL|${BASE_URL}${ASSETS_URL}|g" $NOT_FOUND_PATH
elif [[ $(uname) == 'Darwin' ]]; then
sed -i '' "/$README_START/,/$README_END/d" $NOT_FOUND_PATH
sed -i '' "s|$README_PLACEHOLDER|$README_REPLACEMENT|" $NOT_FOUND_PATH
sed -i '' "s|$ASSETS_URL|${BASE_URL}${ASSETS_URL}|g" $NOT_FOUND_PATH
fi

echo "Created $NOT_FOUND_PATH"
Expand Down

0 comments on commit 47640d7

Please sign in to comment.