<%*
const dv = app.plugins.plugins["dataview"].api;
/* ---------------------------------------
PART 1 — GENERATE INDEX FILE (A–Z)
--------------------------------------- */
const letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("");
const folderPaths = ['"Characters"', '"World Bible"'];
const baseFrom = folderPaths.join(" or ");
let indexOutput = "";
for (const L of letters) {
const query = `LIST FROM (${baseFrom}) WHERE startswith(file.name, "${L}")`;
const result = await dv.queryMarkdown(query);
indexOutput += `## ${L}\n\n${result.value}\n\n`;
}
const indexFilename = "Index";
let indexFile = tp.file.find_tfile(indexFilename);
if (!indexFile) {
indexFile = await tp.file.create_new("", indexFilename);
}
const indexFrontmatter = `---\npublish: true\n---\n\n`;
await app.vault.modify(indexFile, indexFrontmatter + indexOutput);
/* ---------------------------------------
PART 2 — KNOWN SKELT
--------------------------------------- */
async function updateTagList(tag, filename) {
const query = `
LIST
FROM #${tag}
SORT file.name ASC
`;
const r = await dv.queryMarkdown(query);
// no heading
const output = `${r.value}\n\n`;
let file = tp.file.find_tfile(filename);
if (!file) {
file = await tp.file.create_new("", filename);
}
const fm = `---\npublish: true\n---\n\n`;
await app.vault.modify(file, fm + output);
}
// Update Skelt
await updateTagList("Skelt", "Known Skelt");
// Update Human
await updateTagList("Human", "Known Human");
// Update Half-Skelt (tag must be "Half-Skelt" in your notes)
await updateTagList("Half-Skelt", "Known Half-Skelt");
%>