From bece8fcab6e12db79617dcbcccb174d299140b51 Mon Sep 17 00:00:00 2001 From: Luis Michaelis Date: Fri, 2 Feb 2024 18:51:34 +0100 Subject: [PATCH] fix: properly handle absolute paths in `CreatedModifiedDate` (#790) When providing an absolute path to the content directory (e.g. when using an Obsidian Vault in another directory), the build step would fail with Failed to process `/absolute/path/to/file.md`: ENOENT: no such file or directory, stat '/current/working/directory/absolute/path/' This problem originated in the `CreatedModifiedDate` transformer which tries to construct a native filesystem path to the file to call `fs.stat` on. It did not however, account for the original file path contained in the received `VFile` being an absolute path and so, just concatenated the current working directory with the absolute path producing a nonexistent one. This patch adds a simple fix for this issue by checking if the original file path is already absolute before concatenating with the current working directory. --- quartz/plugins/transformers/lastmod.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quartz/plugins/transformers/lastmod.ts b/quartz/plugins/transformers/lastmod.ts index 31c8c20..2c7b9ce 100644 --- a/quartz/plugins/transformers/lastmod.ts +++ b/quartz/plugins/transformers/lastmod.ts @@ -43,7 +43,7 @@ export const CreatedModifiedDate: QuartzTransformerPlugin | und let published: MaybeDate = undefined const fp = file.data.filePath! - const fullFp = path.posix.join(file.cwd, fp) + const fullFp = path.isAbsolute(fp) ? fp : path.posix.join(file.cwd, fp) for (const source of opts.priority) { if (source === "filesystem") { const st = await fs.promises.stat(fullFp)