diff --git a/md/test-md-file.md b/md/test-md-file.md
index b1822a2..f1461e5 100644
--- a/md/test-md-file.md
+++ b/md/test-md-file.md
@@ -95,6 +95,9 @@ Add them using an absolute image-url like so:
`https://raw.githubusercontent.com/UnterrainerInformatik/java-http-server/master/docs/standard-request-response-process.png`
![global-image|100x300](https://raw.githubusercontent.com/UnterrainerInformatik/java-http-server/master/docs/standard-request-response-process.png)
+
+### Obsidian Link Images
+![[Pasted image 20240315152828.png]]
### Local Images (path)
Add them using a relative path in your repository like so:
(The base of your path is the path of the current MD-file)
diff --git a/obsidian.js b/obsidian.js
index cc7b3b7..98aff1a 100644
--- a/obsidian.js
+++ b/obsidian.js
@@ -100,6 +100,7 @@ export const callouts = {
// Key is the file-name without path (and no extension for the md-file-list).
// Value is an array of the relative paths to all the files with that name anywhere in the file-system.
// If there is only one file with that name, the array will contain only one element.
+export let dirPrefix = "";
export const mdFilesMap = {};
export const filesMap = {};
export const mdFilesDir = {};
@@ -166,7 +167,8 @@ function makeSafeForCSS(name) {
/**
* If it's the root dir, dirPrefix should be an empty string.
*/
-export async function scanFiles(dirPrefix, dir, root = dir) {
+export async function scanFiles(prefix, dir, root = dir) {
+ dirPrefix = prefix;
scanFilesInternal(dir, root);
let mdFiles = await Promise.all(
Object.keys(mdFilesDir).map(async (file) => {
@@ -178,7 +180,6 @@ export async function scanFiles(dirPrefix, dir, root = dir) {
}
return {
[file]: {
- dirPrefix: dirPrefix,
path: file,
pathWithoutExt: pwe,
folders: folders,
@@ -419,7 +420,7 @@ function preReplaceObsidianFileLinks(html, req) {
}
f = encodeURIComponent(f);
const serverUrl = `${req.protocol}://${req.get("host")}`;
- return `[${alt ? alt : fileName}](${serverUrl}/${f})`;
+ return `[${alt ? alt : fileName}](${serverUrl}/${dirPrefix + f})`;
} else {
return match;
}
@@ -612,7 +613,7 @@ function replaceObsidianImageLinks(html, req) {
}
}
const serverUrl = `${req.protocol}://${req.get("host")}`;
- return ``;
} else {
@@ -798,8 +799,7 @@ function insertDirFolder(folder, j) {
function insertDirLink(file, req, indent, i, files) {
let r = "";
- console.log(file);
- r += `${indentStringFor(file.lastFolder === "" ? 0 : indent)}${
file.fileNameWithoutExtension