// Return modified path based on location
const dv = app.plugins.plugins.dataview.api;
function getPath(location) {
const match = dv.pages(‘“Compendium/Atlas”’)
.where(p ⇒ p.type = 'locale' && p.file.name = location)
.map(obj ⇒ obj.file.path.split(’/‘).slice(2, -1).join(’/’))
.find(Boolean);
return match || '';
}
//
// Main Code Section
//
// Call modal form
const result = await MF.openForm(‘LANDMARK’);
// Set variables after result returns values
const location = result.Location.value;
const name = result.Name.value;
let type = result.Type.value;
const icon = getIcon(type);
const path = getPath(location);
if (type === ‘Manual’) {
type = await tp.system.prompt(‘Enter type:’, ‘Leave blank for none’, true);
type = type === ‘Leave blank for none’ || ” ? ” : type;
}
// Rename, move, & open markdown file
await tp.file.move(Compendium/Atlas/${location ? {path}/` : ''}{name}); await app.workspace.getLeaf(true).openFile(tp.file.find_tfile(name)); new Notice().noticeEl.innerHTML = Finished! New landmark ${name} added`;
_%>