function toIST(num){
let arr = ["st","nd","rd","th"]
let suf
if(num >= 4){suf = arr[3]}else{suf = arr[num - 1]};
return num+suf
};
//Set up veriables
const startingSearch = '"050. Collections/Spell Book" and #SRD'
//Get all pages to get Classes from
const pages = dv.pages(startingSearch);
const classes = [];
//Creates a list of all Classes in the group of spells
for(const p of pages){
for(const c of p.Class){
if(classes.indexOf(c.path) < 0){classes.push(c.path)}
}
}
//Generates h3 Class H4 Spell Level and a table of spells in alfabetical order
for(const CLASS of classes){
let classHeading = CLASS + " Spells"
dv.header(3, classHeading);
let classSearch = startingSearch + " and [[" + CLASS + "]]"
for (let group of dv.pages(classSearch).groupBy(p => p.Level)) {
let header = group.key === 0 ? "Cantrip" : toIST(group.key) + " Level";
dv.header(4, header);
dv.table(["Spell","Casting Time","Duration","Components"],
group.rows
.sort(k => k.file.name, 'asc')
.map(k => [k.file.link, k["Casting Time"],k.Duration,k.Components.Text]))
}
}
Here is the dataview I was able to come up with