Skip to content

Commit

Permalink
fix public path to _file
Browse files Browse the repository at this point in the history
  • Loading branch information
Fil committed Nov 17, 2023
1 parent 07c69ba commit aeab77d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion public/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,8 @@ export function define(cell) {
v.define(outputs.length ? `cell ${id}` : null, inputs, body);
variables.push(v);
for (const o of outputs) variables.push(main.define(o, [`cell ${id}`], (exports) => exports[o]));
for (const f of files) attachedFiles.set(f.name, {url: globalThis._FileAttachmentDir + `${(new URL(f.name, location)).pathname}`, mimeType: f.mimeType}); // prettier-ignore
const fadir = new URL(globalThis._FileAttachmentBase, location).href;
for (const f of files) attachedFiles.set(f.name, {url: new URL(f.name, fadir).pathname, mimeType: f.mimeType});
for (const d of databases) databaseTokens.set(d.name, d);
}

Expand Down
2 changes: 1 addition & 1 deletion src/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ ${Array.from(getImportPreloads(parseResult, path))
<script type="module">
import {${preview ? "open, " : ""}define} from "${relativeUrl(path, "/_observablehq/client.js")}";
globalThis._FileAttachmentDir = ${JSON.stringify(relativeUrl(path, "/_file/"))};
globalThis._FileAttachmentBase = ${JSON.stringify(relativeUrl(path, "/_file" + dirname(path) + "/"))};
${preview ? `open({hash: ${JSON.stringify(hash)}});\n` : ""}${parseResult.cells
.map(resolver)
Expand Down

0 comments on commit aeab77d

Please sign in to comment.