44 lines
1.5 KiB
Markdown
44 lines
1.5 KiB
Markdown
<%*
|
|
const thisFile = tp.config.target_file;
|
|
const campaignData = tp.user.ttrpg.campaignData(thisFile)
|
|
const settingData = tp.user.ttrpg.settingData(thisFile);
|
|
const title = tp.file.title === "Untitled"
|
|
? await tp.system.prompt("Person Name")
|
|
: tp.file.title;
|
|
const genders = {
|
|
"N/A": "it",
|
|
"Male": "he/him",
|
|
"Female": "she/her",
|
|
"Nonbinary": "they/them",
|
|
}
|
|
const types = {"npc": "Non-player Character", "pc": "Player Character"};
|
|
const type = tp.frontmatter.personType ?? await tp.system.suggester(v => types[v], Object.keys(types), true, "Type of Character");
|
|
const gender = tp.frontmatter?.gender ?? (await tp.system.suggester(v => v, Object.keys(genders), false, "Gender") ?? "N/A");
|
|
const pronouns = tp.frontmatter.pronouns ?? genders[gender];
|
|
const metadata = {
|
|
tags: ['ttrpg/person'],
|
|
data: {
|
|
icon: "user",
|
|
title,
|
|
pronunciation: tp.frontmatter.pronunciation ?? "",
|
|
summary: tp.frontmatter?.summary ?? "",
|
|
campaigns: [campaignData.link],
|
|
setting: settingData.link,
|
|
personType: type,
|
|
gender,
|
|
pronouns,
|
|
ancestry: tp.frontmatter?.ancestry ?? "",
|
|
languages: tp.frontmatter?.languages ?? [],
|
|
factions: tp.frontmatter?.factions ?? [],
|
|
location: tp.frontmatter?.location ?? [],
|
|
},
|
|
title,
|
|
};
|
|
if (type === "pc") {
|
|
metadata.data.player = tp.frontmatter?.player ?? await tp.system.prompt("Player Name");
|
|
}
|
|
await tp.user.util.updateMetadata(tp, metadata);
|
|
%>
|
|
|
|
<% tp.file.cursor() %>
|