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'];
|
return ['default.typ'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read directory contents
|
// Read directory contents - convert absolute path to vault-relative
|
||||||
const list = await this.plugin.app.vault.adapter.list(this.templatesPath);
|
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));
|
const files = list.files.map(filePath => path.basename(filePath));
|
||||||
|
|
||||||
// Filter for .typ and .pandoc.typ files
|
// Filter for .typ and .pandoc.typ files
|
||||||
|
|||||||
Reference in new issue
Block a user