Skip to content
Snippets Groups Projects
Verified Commit 689ceedc authored by Rok Štular's avatar Rok Štular
Browse files

fix(thebe): Fix relative URLs

parent ff21c3b1
No related branches found
No related tags found
2 merge requests!40Publish fixes,!38fix(thebe): Fix relative URLs
Pipeline #205669 passed
......@@ -2,13 +2,15 @@
set -euo pipefail
set -euo pipefail
START_SERVER=${1:-false}
PAGE_ROOT=${2:-"/"}
# Build the jupyter book, everything else is post-processing
jupyter-book build book
# Note: the structure of thebe_lite mimicks where thing are needed in the html folder
cp thebe_lite/* book/_build/html/ -r
sed "s,const PAGE_ROOT = \"/\";,const PAGE_ROOT = \"$PAGE_ROOT\";,g" thebe_lite/_static/sphinx-thebe.js > book/_build/html/_static/sphinx-thebe.js
rm book/_build/html/THEBE_LITE.md
# Copy all non notebook, markdown or build files into the build for local access in pyodide etc.
......@@ -40,8 +42,6 @@ if [ "$python_command" = "" ] ; then
fi
# Serves the files on port 8000, localhost (127.0.0.1:8000)
START_SERVER=${1:-false}
if [ "$START_SERVER" = true ] ; then
echo "Starting server on port 8000"
$python_command -m http.server 8000 --directory book/_build/html
......
// Do not touch the following line
const PAGE_ROOT = "/";
// You can touch from here onwards
const thebeLiteConfig = {
requestKernel: true,
useJupyterLite: true,
......@@ -436,8 +440,8 @@ var initThebe = async () => {
console.log("[sphinx-thebe]: Loading thebe...");
$(".thebe-launch-button ").text("Loading thebe...");
await loadScriptAsync("/thebe-lite.min.js");
await loadScriptAsync("/index.js");
await loadScriptAsync(`${PAGE_ROOT}thebe-lite.min.js `);
await loadScriptAsync(`${PAGE_ROOT}index.js`);
// Runs once the script has finished loading
console.log("[sphinx-thebe]: Finished loading thebe...");
......@@ -529,5 +533,5 @@ if (document.readyState !== "loading") {
});
}
loadStyleAsync("/thebe.css");
loadStyleAsync("/_static/code.css");
loadStyleAsync(`${PAGE_ROOT}thebe.css`);
loadStyleAsync(`${PAGE_ROOT}_static/code.css`);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment