// 1) Rename if the file starts with āNewPlanetā
let title;
if (tp.file.title.startsWith(āNewPlanetā)) {
title = await tp.system.prompt(āEnter Planet Nameā);
if (!title) {
new Notice(āNo name entered. Aborting.ā);
return;
}
await tp.file.rename(title);
} else {
title = tp.file.title;
}
// 2) Get all Star System notes from folder
const systemFiles = tp.app.vault.getMarkdownFiles()
.filter(f ā f.path.startsWith(ā2-World/Star Systems/ā));
const placeholderLabel = āš No Star System Selectedā;
const placeholderPath = āplaceholderā;
// 3) Prompt user to pick a Star System
const chosenPath = await tp.system.suggester(systemChoices, systemValues, true);
if (!chosenPath) return;
// 4) Build the wiki-link or set fallback
let wikiLink = null;
if (chosenPath !== placeholderPath) {
const chosenAlias = chosenPath.split(ā/ā).pop().replace(/.md/,ā²ā²);wikiLink=ā[[{chosenPath}|${chosenAlias}]]`;
}
// 5) Write to frontmatter
setTimeout(() ā {
const newFile = tp.file.find_tfile(tp.file.path(true));
if (!newFile) {
new Notice(āCould not find file after rename.ā);
return;
}
app.fileManager.processFrontMatter(newFile, fm ā {
fm[āMyContainerā] = wikiLink ?? āNoneā;
});
}, 200);
%>
Parent Star System: INPUT[suggester(optionQuery(#Category/StarSystem)):MyContainer]