fix(TemplateManager): Convert absolute path to vault-relative for adapter.list()

- Fixed adapter.list() call to use vault-relative path instead of absolute templatesPath
- Added proper path conversion by stripping vault base path and leading separators
- Ensures compatibility with Obsidian's vault.adapter API requirements
- Prevents potential file listing failures due to incorrect path format
- Maintains cross-platform path handling with proper separator normalization

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Jarvis committed 2025-09-25 16:32:21 +02:00
1 parent 97b356a912
commit e084ff38cb
1 file changed
+12 -2
+12 -2
View File
@@ -35,8 +35,18 @@ export class TemplateManager {
return ['default.typ'];
}
// Read directory contents
const list = await this.plugin.app.vault.adapter.list(this.templatesPath);
// Read directory contents - convert absolute path to vault-relative
const vaultBasePath = this.pathUtils.getVaultPath();
let vaultRelativePath = this.templatesPath;
// Convert absolute path to vault-relative path
if (this.templatesPath.startsWith(vaultBasePath)) {
vaultRelativePath = this.templatesPath.substring(vaultBasePath.length);
// Remove leading separators
vaultRelativePath = vaultRelativePath.replace(/^[/\\]+/, '');
}
const list = await this.plugin.app.vault.adapter.list(vaultRelativePath);
const files = list.files.map(filePath => path.basename(filePath));
// Filter for .typ and .pandoc.typ files