Skip to content

Commit a20856b

Browse files
committed
ensure we return a relative path
1 parent e7ce5af commit a20856b

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/format/html/format-html-notebook.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import {
2828
} from "../../command/render/types.ts";
2929
import { render, renderServices } from "../../command/render/render-shared.ts";
3030

31-
import { basename, dirname, join } from "path/mod.ts";
31+
import { basename, dirname, join, relative } from "path/mod.ts";
3232

3333
interface NotebookView {
3434
title: string;
@@ -111,13 +111,14 @@ export async function processNotebookEmbeds(
111111
const title = nbDivEl.getAttribute("data-notebook-title");
112112
const nbDir = dirname(notebookPath);
113113
const filename = basename(notebookPath);
114+
const inputDir = dirname(input);
114115

115116
const nbView = async () => {
116117
if (nbViewConfig) {
117118
// Read options for this notebook
118119
const nbPreviewOptions = nbViewConfig.options(notebookPath);
119120

120-
const nbAbsPath = join(dirname(input), notebookPath);
121+
const nbAbsPath = join(inputDir, notebookPath);
121122
const htmlPreview = await renderHtmlView(
122123
nbAbsPath,
123124
nbPreviewOptions,
@@ -126,7 +127,7 @@ export async function processNotebookEmbeds(
126127
);
127128
return {
128129
title: htmlPreview.title,
129-
href: htmlPreview.href,
130+
href: relative(inputDir, htmlPreview.href),
130131
};
131132
} else {
132133
return {
@@ -220,6 +221,8 @@ export async function processNotebookEmbeds(
220221
}
221222
}
222223

224+
console.log(nbPaths);
225+
223226
// Validate that there are no unused notebooks in the front matter
224227
nbViewConfig.unused(linkedNotebooks);
225228
}
@@ -288,7 +291,7 @@ async function renderHtmlView(
288291
[kTemplate]: templatePath,
289292
[kNotebookViewStyle]: kNotebookViewStyleNotebook,
290293
},
291-
quiet: false,
294+
quiet: true,
292295
},
293296
});
294297

0 commit comments

Comments
 (0)