// 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 = 'region' && 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(‘LOCALE’);
// 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;
}