diff --git a/docs/nginx.conf b/docs/nginx.conf
index 36236be..acae827 100644
--- a/docs/nginx.conf
+++ b/docs/nginx.conf
@@ -1,5 +1,9 @@
root $dir_path;
+if ($deploy_path = "") {
+ set $deploy_path "/";
+}
+
# The MeowIndex web app block
location /__meowindex__ {
alias /etc/nginx/MeowIndex/dist;
@@ -7,7 +11,8 @@ location /__meowindex__ {
# Use sub_filter to configure the app
sub_filter_types application/javascript;
sub_filter_once off;
- sub_filter "{DEPLOY-PATH-PLACEHOLDER}" "/__meowindex__";
+ sub_filter "{ASSETS-PATH-PLACEHOLDER}" "/__meowindex__";
+ sub_filter "{DEPLOY-PATH-PLACEHOLDER}" $deploy_path;
sub_filter "{HOST-PLACEHOLDER}" "/api";
sub_filter "\"/assets" "\"/__meowindex__/assets";
sub_filter "File Listing" $title;
diff --git a/src/App.tsx b/src/App.tsx
index bf46560..1a04d36 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -26,10 +26,12 @@ interface File {
const getType = (f: File) => f.type ?? f.file_type
// Placeholder for nginx to replace
+let assetsPath = "{ASSETS-PATH-PLACEHOLDER}"
let deployPath = "{DEPLOY-PATH-PLACEHOLDER}"
let host = "{HOST-PLACEHOLDER}"
-// Default deploy path and host for testing
+// Default paths and host for testing
+if (assetsPath.includes("-PLACEHOLDER")) assetsPath = "/"
if (deployPath.includes("-PLACEHOLDER")) deployPath = "/"
if (host.includes("-PLACEHOLDER")) host = "https://daisy.hydev.org/data/api"
@@ -47,14 +49,14 @@ const fetchApi = async () =>
function getIcon(f: File)
{
- if (getType(f) == "directory") return urlJoin(deployPath, "mime/folder.svg")
+ if (getType(f) == "directory") return urlJoin(assetsPath, "mime/folder.svg")
if (f.has_thumb) return urlJoin(host, filePath, f.name) + "?thumb=1"
const sp = f.name.split(".")
const m = f.mime ?? mime.getType(sp[sp.length - 1])
- if (m) return urlJoin(deployPath, `mime/${m.replace("/", "-")}.svg`)
- else return urlJoin(deployPath, 'mime/application-blank.svg')
+ if (m) return urlJoin(assetsPath, `mime/${m.replace("/", "-")}.svg`)
+ else return urlJoin(assetsPath, 'mime/application-blank.svg')
}
function getHref(f: File)
@@ -67,7 +69,7 @@ const alpNum = new Set("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRST
export default function App() {
const [api] = createResource(fetchApi)
- const paths = [window.location.host, ...filePath.split("/").filter(it => it)]
+ const paths = [window.location.host, ...fullPath.split("/").filter(it => it)]
// Infinite Scroll
const [scrollIndex, setScrollIndex] = createSignal(50)
@@ -150,7 +152,7 @@ export default function App() {
<>
{decodeURIComponent(p)}
+ href={urlJoin(fullPath, "../".repeat(paths.length - i() - 1))}>{decodeURIComponent(p)}
/
>
}