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:
1 file changed
+12
-2
@@ -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
|
||||
|
||||
Reference in new issue
Block a user