Luis Michaelis
2024-02-02 bece8fcab6e12db79617dcbcccb174d299140b51
refs
author Luis Michaelis <me@lmichaelis.de>
Friday, February 2, 2024 17:51 +0000
committer GitHub <noreply@github.com>
Friday, February 2, 2024 17:51 +0000
commitbece8fcab6e12db79617dcbcccb174d299140b51
tree 043af7b60b1793091dba63f5111930be7a60b123 tree | zip | gz
parent 18745a9dc68d26827ea0df99dcc709e311c74a98 view | diff
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.
1 files modified
2 ■■■ changed files
quartz/plugins/transformers/lastmod.ts 2 ●●● diff | view | raw | blame | history