Astro+Directus(Visual-Editing)+Snipcart Test-Stack
This commit is contained in:
+21
@@ -0,0 +1,21 @@
|
||||
import path from "node:path";
|
||||
import url from "node:url";
|
||||
import { appendForwardSlash } from "@astrojs/internal-helpers/path";
|
||||
const STATIC_HEADERS_FILE = "_experimentalHeaders.json";
|
||||
function resolveClientDir(options) {
|
||||
const clientURLRaw = new URL(options.client);
|
||||
const serverURLRaw = new URL(options.server);
|
||||
const rel = path.relative(url.fileURLToPath(serverURLRaw), url.fileURLToPath(clientURLRaw));
|
||||
const serverFolder = path.basename(options.server);
|
||||
let serverEntryFolderURL = path.dirname(import.meta.url);
|
||||
while (!serverEntryFolderURL.endsWith(serverFolder)) {
|
||||
serverEntryFolderURL = path.dirname(serverEntryFolderURL);
|
||||
}
|
||||
const serverEntryURL = serverEntryFolderURL + "/entry.mjs";
|
||||
const clientURL = new URL(appendForwardSlash(rel), serverEntryURL);
|
||||
return url.fileURLToPath(clientURL);
|
||||
}
|
||||
export {
|
||||
STATIC_HEADERS_FILE,
|
||||
resolveClientDir
|
||||
};
|
||||
Reference in New Issue
Block a user