Skip to content

Commit

Permalink
feat(404): use better absolute url scheme
Browse files Browse the repository at this point in the history
`/..` makes it relative to the URL without us having to specify the
domain name.
  • Loading branch information
sanjayankur31 committed Jan 3, 2025
1 parent db57efa commit 1824623
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ jobs:
jupyter-book build ./source
- name: Update locations in 404 page
run: |
sed -i 's|href="_static|href="https://docs.neuroml.org/_static|g' ./source/_build/html/404.html
sed -i 's|src="_static|src="https://docs.neuroml.org/_static|g' ./source/_build/html/404.html
sed -i 's|src="\([[:alnum:]_]\)|src="/\1|g' ./source/_build/html/404.html
sed -i 's|href="\([[:alnum:]_]\)|href="/\1|g' ./source/_build/html/404.html
# if we also replaced "http.." with "/http..", undo that
sed -i 's|href="/http|href="http|g' ./source/_build/html/404.html
sed -i 's|src="/http|src="http|g' ./source/_build/html/404.html
- name: Import to GitHub pages
run: |
ghp-import -c "docs.neuroml.org" -n -p -f ./source/_build/html
9 changes: 7 additions & 2 deletions build-helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,17 @@ function build_book() {
enable_virtenv
echo "Building book."
jupyter-book build ./source
sed -i 's|href="_static|href="https://docs.neuroml.org/_static|g' ./source/_build/html/404.html
sed -i 's|src="_static|src="https://docs.neuroml.org/_static|g' ./source/_build/html/404.html
}

function publish_book() {
enable_virtenv
echo "Updating URLs for 404.html"
sed -i 's|src="\([[:alnum:]_]\)|src="/\1|g' ./source/_build/html/404.html
sed -i 's|href="\([[:alnum:]_]\)|href="/\1|g' ./source/_build/html/404.html
# if we also replaced "http.." with "/http..", undo that
sed -i 's|href="/http|href="http|g' ./source/_build/html/404.html
sed -i 's|src="/http|src="http|g' ./source/_build/html/404.html

echo "Publishing book."
ghp-import -c "docs.neuroml.org" -n -p -f ./source/_build/html
}
Expand Down

0 comments on commit 1824623

Please sign in to comment.