I mark things which I want to study by [[Study]] for the Note or by Task - [?] for something inside the Note.
To get a table of all material related to Study I use the following script:
const currentNotePath = dv.current().file.path;
const currentNoteName = dv.current().file.name;
let tasksByNote = {};
let notesReferencingCurrent = [];
let tableData = [];
const notes = dv.pages()
.where(p => p.file.outlinks.some(link => link.path === currentNotePath))
.map(p => [p.file.name, p.file.link, p.file.ctime.toFormat("yyyy-MM-dd")]);
dv.pages()
.where(p => p.file.tasks) // Фильтруем только файлы с задачами
.forEach(p => {
if (p.file.tasks) {
p.file.tasks
.filter(t => t.status === "?") // Только задачи со статусом "?"
.forEach(t => {
if (!tasksByNote[p.file.name]) {
tasksByNote[p.file.name] = [];
}
tasksByNote[p.file.name].push({
text: t.text,
created: t.created ? t.created.toFormat("yyyy-MM-dd") : p.file.ctime.toFormat("yyyy-MM-dd") // Дата создания задачи или заметки
});
});
}
});
let allNotes = new Set();
notes.forEach(note => {
allNotes.add(note[0]);
});
for (let note in tasksByNote) {
allNotes.add(note);
}
let sortedNotes = Array.from(allNotes).sort();
sortedNotes.forEach(note => {
// Добавляем заметку
tableData.push([`[[${note}]]`, "", tasksByNote[note] ? tasksByNote[note][0].created : notes.find(n => n[0] === note)?.[2] || ""]);
// Если у заметки есть задачи, добавляем их
if (tasksByNote[note]) {
tasksByNote[note].forEach((task, index) => {
if (index > 0) { // Первая задача уже добавлена вместе с заметкой
tableData.push(["", `- [?] ${task.text}`, task.created]);
} else {
tableData[tableData.length - 1][1] = `- [?] ${task.text}`; // Обновляем задачу в строке заметки
}
});
}
});
dv.table(
["Note", "Task", "Date"],
tableData
);