Skip to content

Commit

Permalink
Allow overwrite of an empty location property
Browse files Browse the repository at this point in the history
The "Add geolocation (front matter) to current note" action correctly
avoids overwriting an existing location property. But I'm fussy about
the order of properties in my location notes, so I prefer to apply a
template with an empty location property in the right place. This
change allows the action to overwrite an existing entry if it is null.
  • Loading branch information
zakj committed Aug 16, 2024
1 parent d594e10 commit 4f6169d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,11 @@ export async function verifyOrAddFrontMatter(
): Promise<boolean> {
let locationAdded = false;
await app.fileManager.processFrontMatter(file, (frontmatter: any) => {
if (fieldName in frontmatter && skipIfExists) {
if (
fieldName in frontmatter &&
frontmatter[fieldName] !== null &&
skipIfExists
) {
locationAdded = false;
return;
}
Expand Down

0 comments on commit 4f6169d

Please sign in to comment.