Skip to content

Commit 13d3032

Browse files
committed
Fix file-relative error and preview problems on change
1 parent 3096c61 commit 13d3032

File tree

4 files changed

+22
-8
lines changed

4 files changed

+22
-8
lines changed

_extensions/sverto/create-imports.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ local preprocess_qmd_filter = {
8181
-- /site_libs/quarto-ojs
8282
block.text = block_text:gsub(
8383
svelte_import_syntax,
84-
"import(\"./../../%1.js\");")
84+
"import(\"./../../" .. current_qmd_path .. "%1.js\");")
8585

8686
end
8787
return block

_extensions/sverto/refresh.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
// delete the temporary import block files and the temp render metadata
2-
try {
3-
await Deno.remove(".sverto/", { recursive: true })
4-
} catch {
52

3+
if (Deno.env.get("QUARTO_PROJECT_RENDER_ALL") == "1") {
4+
try {
5+
await Deno.remove(".sverto/", { recursive: true })
6+
} catch {
7+
8+
}
69
}
10+

docs/_extensions/sverto/create-imports.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ local preprocess_qmd_filter = {
7272

7373
-- first, extract .svelte paths in import_svelte() statements
7474
for svelte_path in block_text:gmatch(svelte_import_syntax) do
75+
print("Sending to Svelte compiler: " ..
76+
current_qmd_path .. svelte_path .. ".svelte\n")
7577
append_to_file(".sverto/.sverto-imports",
7678
current_qmd_path .. svelte_path .. ".svelte\n")
7779
end
@@ -81,7 +83,7 @@ local preprocess_qmd_filter = {
8183
-- /site_libs/quarto-ojs
8284
block.text = block_text:gsub(
8385
svelte_import_syntax,
84-
"import(\"./../../%1.js\");")
86+
"import(\"./../../" .. current_qmd_path .. "%1.js\");")
8587

8688
end
8789
return block
@@ -124,6 +126,7 @@ for key, qmd_path in ipairs(in_files) do
124126
-- local svelte_files = {}
125127
local transformed_doc = doc:walk(preprocess_qmd_filter)
126128
create_dir_recursively(".sverto/" .. path_dir(qmd_path))
129+
print("Creating .sverto/" .. qmd_path)
127130
write_file(".sverto/" .. qmd_path, pandoc.write(transformed_doc, "markdown"))
128131

129132
end

docs/_extensions/sverto/refresh.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
// delete the temporary import block files and the temp render metadata
2-
try {
3-
await Deno.remove(".sverto/", { recursive: true })
4-
} catch {
52

3+
console.log("Render all? " + Deno.env.get("QUARTO_PROJECT_RENDER_ALL"))
4+
5+
if (Deno.env.get("QUARTO_PROJECT_RENDER_ALL") == "1") {
6+
console.log("Clearing .sverto/")
7+
try {
8+
await Deno.remove(".sverto/", { recursive: true })
9+
} catch {
10+
11+
}
612
}
13+

0 commit comments

Comments
 (0)