Skip to content

Commit

Permalink
fix: get uid from frontmatter
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinzent03 committed Mar 9, 2022
1 parent ed49780 commit 12f8076
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,7 @@ export default class AdvancedURI extends Plugin {
async generateURI(parameters: Parameters) {
let uri = `obsidian://advanced-uri?vault=${this.app.vault.getName()}`;
const file = this.app.vault.getAbstractFileByPath(parameters.filepath);

if (this.settings.useUID && file instanceof TFile) {
parameters.filepath = undefined;
parameters.uid = await this.getUIDFromFile(file);
Expand Down Expand Up @@ -727,7 +728,7 @@ export default class AdvancedURI extends Plugin {
async getUIDFromFile(file: TFile): Promise<string> {
const frontmatter = this.app.metadataCache.getFileCache(file).frontmatter;
let uid = parseFrontMatterEntry(frontmatter, this.settings.idField);
if (uid) return;
if (uid != undefined) return uid;
return await this.writeUIDToFile(file, uuidv4());
};

Expand Down

0 comments on commit 12f8076

Please sign in to comment.