<%* // // Helper Functions //

// Convert string to camelCase function toCamelCase(str) { return str.replace(/(?:^\w|[A-Z]|\b\w)/g, (word, index) index === 0 ? word.toLowerCase() : word.toUpperCase()).replace(/\s+/g, ”); }

// Return icon based on type function getIcon(type) { const iconMappings = { Country: ‘:FasFlag:’, ‘General Region’: ‘:FasMap:’, Kingdom: ‘:FasChessRook:’, Nation: ‘:FasFlag:’ };

return iconMappings[type] || ‘:FasCircleQuestion:’; }

// 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 = "continent" || p.type = “ocean”) && 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(‘REGION’);

// Declare variables after form returns values const location = result.Location.value; const name = result.Name.value; const type = result.Type.value; const icon = getIcon(type); const path = getPath(location);

// Rename, move, & open note await tp.file.move(Compendium/Atlas/${location ? {path}/` : ''}{name}/{name} added`; _%>


type: region locations:

  • <% location ? "[[${location}]]" : ” %> tags:
  • <% type ? location/${toCamelCase(type)} : ” %> headerLink: ”<% name %>

banner

<% name %>

<% type ? ${icon} ${type} : ” %>


SUMMARY

Description of the <% type ? type.toLowerCase() : ‘region’ %> <% name %>.

marker

Column

dv.container.className += ’ npcDirect’; dv.list(dv.pages(‘“Compendium/NPC’s”’) .where(p p.file.outlinks.includes(dv.current().file.link)) .sort(p p.file.link) .map(p p.headerLink), 1);

```dataviewjs

dv.container.className += ’ npcChild’; let page = dv.current().file.path; let pages = new Set(); let stack = [page]; while (stack.length > 0) { let elem = stack.pop(); let meta = dv.page(elem); if (!meta) continue; for (let inlink of meta.file.inlinks.concat(meta.file.outlinks).array()) { let locations = dv.page(inlink.path); if (!locations || pages.has(inlink.path) || inlink.path === meta.locations?.[0]) continue; if (dv.array(locations.locations).join(”, “).includes(meta.file.path)) { pages.add(inlink.path); stack.push(inlink.path); }}} let data = Array.from(pages) .filter(p dv.page(p)?.type === “npc”) .map(p dv.page(p).headerLink) .sort((a, b) { if (a < b) return -1; if (a > b) return 1; return 0; }); dv.list(data);

LIST WITHOUT ID headerLink FROM “Compendium/Atlas/<% location ? ${path}/ : ” %><% name %>” WHERE type= “locale” SORT file.name ASC

LIST WITHOUT ID headerLink FROM “Session Notes” AND <% name %> SORT file.ctime DESC

marker