Skip to content

Instantly share code, notes, and snippets.

@jhilker98
Created November 8, 2023 22:12
Show Gist options
  • Save jhilker98/15119e7e96e40a665b45df0ec353e209 to your computer and use it in GitHub Desktop.
Save jhilker98/15119e7e96e40a665b45df0ec353e209 to your computer and use it in GitHub Desktop.
<%*
const app = this.app;
const dv = app.plugins.plugins["dataview"].api;
// general metadata
const dob = await tp.user.chooseDate(tp, "Date of Birth");
const characterGender = await tp.system.suggester(["Male", "Female", "Non-binary"], ["Male", "Female", "Non-binary"], false, "Character's gender")
const characterOrientation = await tp.system.suggester(["Straight", "Gay", "Bi", "Unknown"], ["Heterosexual", "Homosexual", "Bisexual", "N/A"], false, "Character's sexual orientation")
const characterRole = await tp.system.suggester(["Main Character", "Major Character (Non-POV)", "Side Character", "Extra Character", "Antagonist"], ["_Main", "_Major", "_Side", "_Extra", "_Antagonist"], false, "Character's role in story")
// process if character is dead
let isDead = await tp.system.suggester(["True", "False"], [true, false], false, "Is the character dead?");
// process first appearance
let stories = dv.pages("#Story").file.sort(n => n.frontmatter.longform.title);
let names = stories.name;
let titles = stories.frontmatter.title;
let links = stories.link;
let firstAppChoice = await tp.system.suggester(titles, links, false, "First Appearance");
const firstApp = dv.page(firstAppChoice.path)
// parse metadata
await app.fileManager.processFrontMatter(tp.config.target_file, (fm) => {
fm.dob = dob
fm.Gender = characterGender
fm.Sexuality = characterOrientation
fm.Role = characterRole
fm.description = ""
fm.firstAppearance = `[[${firstAppChoice.path}|${firstApp.file.frontmatter.title}]]`
fm.tags = [
"inbox",
`Character/${characterRole}`,
]
})
if (isDead) {
let dod = await tp.user.chooseDate(tp, "Date of Death")
await app.fileManager.processFrontMatter(tp.config.target_file, (fm) => {
fm.dead = isDead
fm.dod = dod
})
}
-%>
> [!infobox|right wikipedia wsmall n-th]
> # `=this.file.name`
> _ADD IMAGE_
> ###### Basics
> | | |
> | - | - |
> | **Age** | `=[[ashes]].currentDate.year - this.dob.year`
> | **Gender** | `=this.Gender` |
> | **Sexuality** | `=this.Sexuality` |
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment