Skip to content

Commit

Permalink
feat: ✨ Create note if it doesn't exist
Browse files Browse the repository at this point in the history
Applies to all Breadcrumb links, in the trail, l/m view, visualisations, etc
  • Loading branch information
SkepticMystic committed Aug 22, 2021
1 parent 14aaebe commit 44485db
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/sharedFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,17 @@ export async function openOrSwitch(
event: MouseEvent
): Promise<void> {
const { workspace } = app;
const destFile = app.metadataCache.getFirstLinkpathDest(dest, currFile.path);
let destFile = app.metadataCache.getFirstLinkpathDest(dest, currFile.path);

if (!destFile) {
const newFileFolder = app.fileManager.getNewFileParent(currFile.path).path;
const newFilePath = `${newFileFolder}${newFileFolder === "/" ? "" : "/"}${dest}.md`;
await app.vault.create(newFilePath, "");
destFile = app.metadataCache.getFirstLinkpathDest(
newFilePath,
currFile.path
);
}

const openLeaves: WorkspaceLeaf[] = [];
// For all open leaves, if the leave's basename is equal to the link destination, rather activate that leaf instead of opening it in two panes
Expand Down

0 comments on commit 44485db

Please sign in to comment.